[gmx-developers] Patching mdrun to implement complicated electric field

Mohammad Hassan Khatami MohammadHassan.Khatami at uoit.ca
Mon Oct 7 18:43:17 CEST 2019


Hello
I am planning to implement complicated position-dependent electric field. There is a trick for older versions of gromacs in C language, which is posted on the gromacs developers zone
(http://www.gromacs.org/Developer_Zone/Programming_Guide/Patching_mdrun). I have implemented it in older version of gmx, however, I have difficulties for the new version.


In the older version, the calc_f_el function is as below:

static void calc_f_el(FILE *fp, int  start, int homenr,
                       real charge[], rvec x[], rvec f[],
                       t_cosines Ex[], t_cosines Et[], double t)

However, in the new version, it is as below:

static void calc_f_el(FILE *fp, int  start, int homenr,
                       real charge[], rvec f[],
                       t_cosines Ex[], t_cosines Et[], double t)


And I guess it does not have the position dependency (because it does not have rvec x[]).
OK. So I added rvec x[] to the function in the new version and it compiles.


However, when I try to implement the modification in (http://www.gromacs.org/Developer_Zone/Programming_Guide/Patching_mdrun<http://www.gromacs.org/Developer_Zone/Programming_Guide/>), by adding the box the same way that I did in old version of gmx, it does not compile.


~~~Here I add  real box as suggested in gmx Patching_mdrun<http://www.gromacs.org/Developer_Zone/Programming_Guide/> section ~~~~~
static void calc_f_el(FILE *fp, int  start, int homenr,
                       real charge[], rvec x[], rvec f[],
                       t_cosines Ex[], t_cosines Et[], double t, real box)
{
##My code
}

And I get the following errors:


/home/mkhatami/Downloads/gromacs-2016.4-electricfield-edited/src/gromacs/mdlib/sim_util.cpp: In function ‘void do_force_cutsVERLET(FILE*, t_commrec*, t_inputrec*, gmx_int64_t, t_nrnb*, gmx_wallcycle_t, gmx_localtop_t*, gmx_groups_t*, real (*)[3], real (*)[3], history_t*, real (*)[3], real (*)[3], t_mdatoms*, gmx_enerdata_t*, t_fcdata*, real*, t_graph*, t_forcerec*, interaction_const_t*, gmx_vsite_t*, real*, double, FILE*, gmx_edsam_t, gmx_bool, int)’:
/home/mkhatami/Downloads/gromacs-2016.4-electricfield-edited/src/gromacs/mdlib/sim_util.cpp:1524:57: error: cannot convert ‘real (*)[3] {aka float (*)[3]}’ to ‘real** {aka float**}’ for argument ‘10’ to ‘void calc_f_el(FILE*, int, int, real*, real (*)[3], real (*)[3], t_cosines*, t_cosines*, double, real**)’
                       inputrec->ex, inputrec->et, t, box);
                                                         ^
/home/mkhatami/Downloads/gromacs-2016.4-electricfield-edited/src/gromacs/mdlib/sim_util.cpp: In function ‘void do_force_cutsGROUP(FILE*, t_commrec*, t_inputrec*, gmx_int64_t, t_nrnb*, gmx_wallcycle_t, gmx_localtop_t*, gmx_groups_t*, real (*)[3], real (*)[3], history_t*, real (*)[3], real (*)[3], t_mdatoms*, gmx_enerdata_t*, t_fcdata*, real*, t_graph*, t_forcerec*, gmx_vsite_t*, real*, double, FILE*, gmx_edsam_t, gmx_bool, int)’:
/home/mkhatami/Downloads/gromacs-2016.4-electricfield-edited/src/gromacs/mdlib/sim_util.cpp:1899:57: error: cannot convert ‘real (*)[3] {aka float (*)[3]}’ to ‘real** {aka float**}’ for argument ‘10’ to ‘void calc_f_el(FILE*, int, int, real*, real (*)[3], real (*)[3], t_cosines*, t_cosines*, double, real**)’
                       inputrec->ex, inputrec->et, t, box);



Best,
Mohammad




More information about the gromacs.org_gmx-developers mailing list