2 * mdrun.c - main code to run a md simulation
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
11 #include "potentials/harmonic_oscillator.h"
12 #include "potentials/lennard_jones.h"
13 #include "potentials/albe.h"
15 #include "potentials/tersoff_orig.h"
17 #include "potentials/tersoff.h"
26 int mdrun_usage(void) {
28 printf("%s usage:\n",ME);
33 int mdrun_parse_argv(t_mdrun *mdrun,int argc,char **argv) {
40 printf("%s unknown switch: %s\n",ME,argv[i]);
46 strncpy(mdrun->cfile,argv[++i],128);
49 strncpy(mdrun->sdir,argv[++i],128);
55 printf("%s unknown option: %s\n",ME,argv[i]);
65 int del_stages(t_mdrun *mdrun) {
78 stage=sl->current->data;
81 } while(list_next_f(sl)!=L_NO_NEXT_ELEMENT);
86 int add_stage(t_mdrun *mdrun,u8 type,void *params) {
93 case STAGE_DISPLACE_ATOM:
94 psize=sizeof(t_displace_atom_params);
96 case STAGE_INSERT_ATOMS:
97 psize=sizeof(t_insert_atoms_params);
99 case STAGE_INSERT_MIXED_ATOMS:
100 psize=sizeof(t_insert_mixed_atoms_params);
103 psize=sizeof(t_continue_params);
106 psize=sizeof(t_anneal_params);
109 psize=sizeof(t_chaattr_params);
112 psize=sizeof(t_chsattr_params);
115 printf("%s unknown stage type: %02x\n",ME,type);
119 stage=malloc(sizeof(t_stage));
121 perror("[mdrun] malloc (add stage)");
126 stage->executed=FALSE;
128 stage->params=malloc(psize);
129 if(stage->params==NULL) {
130 perror("[mdrun] malloc (stage params)");
134 memcpy(stage->params,params,psize);
136 list_add_immediate_f(&(mdrun->stage),stage);
141 int mdrun_parse_config(t_mdrun *mdrun) {
151 t_displace_atom_params dap;
152 t_insert_atoms_params iap;
153 t_insert_mixed_atoms_params imp;
154 t_continue_params cp;
156 t_chaattr_params cap;
157 t_chsattr_params csp;
159 /* open config file */
160 fd=open(mdrun->cfile,O_RDONLY);
162 snprintf(error,128,"%s open cfile %s",ME,mdrun->cfile);
167 /* read, parse, set */
172 ret=get_line(fd,line,128);
176 // ignore # lines and \n
177 if((line[0]=='#')|(ret==1))
181 memset(&iap,0,sizeof(t_insert_atoms_params));
182 memset(&imp,0,sizeof(t_insert_mixed_atoms_params));
183 memset(&cp,0,sizeof(t_continue_params));
184 memset(&ap,0,sizeof(t_anneal_params));
185 memset(&cap,0,sizeof(t_chaattr_params));
186 memset(&csp,0,sizeof(t_chsattr_params));
188 // get command + args
192 wptr=strtok(NULL," \t");
194 wptr=strtok(line," \t");
197 strncpy(word[wcnt],wptr,64);
201 if(!strncmp(word[0],"potential",9)) {
202 if(!strncmp(word[1],"albe",4))
203 mdrun->potential=MOLDYN_POTENTIAL_AM;
204 if(!strncmp(word[1],"tersoff",7))
205 mdrun->potential=MOLDYN_POTENTIAL_TM;
206 if(!strncmp(word[1],"ho",2))
207 mdrun->potential=MOLDYN_POTENTIAL_HO;
208 if(!strncmp(word[1],"lj",2))
209 mdrun->potential=MOLDYN_POTENTIAL_LJ;
211 else if(!strncmp(word[0],"continue",8))
212 strncpy(mdrun->continue_file,word[1],128);
213 else if(!strncmp(word[0],"cutoff",6))
214 mdrun->cutoff=atof(word[1]);
215 else if(!strncmp(word[0],"nnd",3))
216 mdrun->nnd=atof(word[1]);
217 else if(!strncmp(word[0],"intalgo",7)) {
218 if(!strncmp(word[1],"verlet",5))
219 mdrun->intalgo=MOLDYN_INTEGRATE_VERLET;
221 else if(!strncmp(word[0],"timestep",8))
222 mdrun->timestep=atof(word[1]);
223 else if(!strncmp(word[0],"volume",6)) {
224 mdrun->dim.x=atof(word[1]);
225 mdrun->dim.y=atof(word[2]);
226 mdrun->dim.z=atof(word[3]);
227 if(strncmp(word[4],"0",1))
230 else if(!strncmp(word[0],"pbc",3)) {
231 if(strncmp(word[1],"0",1))
235 if(strncmp(word[2],"0",1))
239 if(strncmp(word[3],"0",1))
244 else if(!strncmp(word[0],"temperature",11))
245 mdrun->temperature=atof(word[1]);
246 else if(!strncmp(word[0],"pressure",8))
247 mdrun->pressure=atof(word[1]);
248 else if(!strncmp(word[0],"lattice",7)) {
249 if(!strncmp(word[1],"zincblende",10))
250 mdrun->lattice=ZINCBLENDE;
251 if(!strncmp(word[1],"fcc",3))
253 if(!strncmp(word[1],"diamond",7))
254 mdrun->lattice=DIAMOND;
255 if(!strncmp(word[1],"none",4))
258 else if(!strncmp(word[0],"element1",8)) {
259 mdrun->element1=atoi(word[1]);
260 mdrun->m1=pse_mass[mdrun->element1];
262 else if(!strncmp(word[0],"element2",8)) {
263 mdrun->element2=atoi(word[1]);
264 mdrun->m2=pse_mass[mdrun->element2];
266 else if(!strncmp(word[0],"fill",6)) {
267 // only lc mode by now
268 mdrun->lx=atoi(word[2]);
269 mdrun->ly=atoi(word[3]);
270 mdrun->lz=atoi(word[4]);
271 mdrun->lc=atof(word[5]);
273 else if(!strncmp(word[0],"aattr",5)) {
274 // for aatrib line we need a special stage
275 // containing one schedule of 0 loops ...
276 for(i=0;i<strlen(word[1]);i++) {
279 cap.type|=CHAATTR_TOTALV;
282 cap.type|=CHAATTR_REGION;
285 cap.type|=CHAATTR_ELEMENT;
292 if(cap.type&CHAATTR_REGION) {
293 cap.x0=atof(word[1]);
294 cap.y0=atof(word[2]);
295 cap.z0=atof(word[3]);
296 cap.x1=atof(word[4]);
297 cap.y1=atof(word[5]);
298 cap.z1=atof(word[6]);
301 if(cap.type&CHAATTR_ELEMENT) {
302 cap.element=atoi(word[i]);
305 for(o=0;o<strlen(word[i]);o++) {
308 cap.attr|=ATOM_ATTR_VB;
311 cap.attr|=ATOM_ATTR_HB;
314 cap.attr|=ATOM_ATTR_VA;
317 cap.attr|=ATOM_ATTR_FP;
320 cap.attr|=ATOM_ATTR_1BP;
323 cap.attr|=ATOM_ATTR_2BP;
326 cap.attr|=ATOM_ATTR_3BP;
332 add_stage(mdrun,STAGE_CHAATTR,&cap);
334 else if(!strncmp(word[0],"sattr",5)) {
335 // for satrib line we need a special stage
336 // containing one schedule of 0 loops ...
338 for(i=1;i<wcnt;i++) {
339 if(!strncmp(word[i],"pctrl",5)) {
340 csp.ptau=0.01/(atof(word[++i])*GPA);
341 csp.type|=CHSATTR_PCTRL;
343 if(!strncmp(word[i],"tctrl",5)) {
344 csp.ttau=atof(word[++i]);
345 csp.type|=CHSATTR_TCTRL;
347 if(!strncmp(word[i],"prelax",6)) {
348 csp.dp=atof(word[++i])*BAR;
349 csp.type|=CHSATTR_PRELAX;
351 if(!strncmp(word[i],"trelax",6)) {
352 csp.dt=atof(word[++i]);
353 csp.type|=CHSATTR_TRELAX;
355 if(!strncmp(word[i],"rsteps",6)) {
356 csp.rsteps=atoi(word[++i]);
357 csp.type|=CHSATTR_RSTEPS;
359 if(!strncmp(word[i],"avgrst",6)) {
360 csp.avgrst=atoi(word[++i]);
361 csp.type|=CHSATTR_AVGRST;
364 add_stage(mdrun,STAGE_CHSATTR,&csp);
366 else if(!strncmp(word[0],"prerun",6))
367 mdrun->prerun=atoi(word[1]);
368 else if(!strncmp(word[0],"avgskip",7))
369 mdrun->avgskip=atoi(word[1]);
370 else if(!strncmp(word[0],"elog",4))
371 mdrun->elog=atoi(word[1]);
372 else if(!strncmp(word[0],"tlog",4))
373 mdrun->tlog=atoi(word[1]);
374 else if(!strncmp(word[0],"plog",4))
375 mdrun->plog=atoi(word[1]);
376 else if(!strncmp(word[0],"vlog",4))
377 mdrun->vlog=atoi(word[1]);
378 else if(!strncmp(word[0],"save",4))
379 mdrun->save=atoi(word[1]);
380 else if(!strncmp(word[0],"visualize",9))
381 mdrun->visualize=atoi(word[1]);
382 else if(!strncmp(word[0],"stage",5)) {
383 // for every stage line, add a stage
384 if(!strncmp(word[1],"displace",8)) {
385 dap.nr=atoi(word[2]);
386 dap.dx=atof(word[3]);
387 dap.dy=atof(word[4]);
388 dap.dz=atof(word[5]);
389 add_stage(mdrun,STAGE_DISPLACE_ATOM,&dap);
391 else if(!strncmp(word[1],"ins_atoms",9)) {
392 iap.ins_steps=atoi(word[2]);
393 iap.ins_atoms=atoi(word[3]);
394 iap.element=atoi(word[4]);
395 iap.brand=atoi(word[5]);
396 for(i=0;i<strlen(word[6]);i++) {
399 iap.attr|=ATOM_ATTR_VB;
402 iap.attr|=ATOM_ATTR_HB;
405 iap.attr|=ATOM_ATTR_VA;
408 iap.attr|=ATOM_ATTR_FP;
411 iap.attr|=ATOM_ATTR_1BP;
414 iap.attr|=ATOM_ATTR_2BP;
417 iap.attr|=ATOM_ATTR_3BP;
427 iap.x0=atof(word[8]);
428 iap.y0=atof(word[9]);
429 iap.z0=atof(word[10]);
432 if(word[8][0]=='t') {
434 iap.cr=atof(word[9]);
438 iap.x0=atof(word[8]);
439 iap.y0=atof(word[9]);
440 iap.z0=atof(word[10]);
441 iap.x1=atof(word[11]);
442 iap.y1=atof(word[12]);
443 iap.z1=atof(word[13]);
444 iap.cr=atof(word[14]);
449 add_stage(mdrun,STAGE_INSERT_ATOMS,&iap);
455 else if(!strncmp(word[1],"ins_m_atoms",11)) {
456 imp.element1=atoi(word[2]);
457 imp.element2=atoi(word[3]);
458 imp.amount1=atoi(word[4]);
459 imp.amount2=atoi(word[5]);
460 imp.brand1=atoi(word[6]);
461 imp.brand2=atoi(word[7]);
462 imp.crmin=atof(word[8]);
463 imp.crmax=atof(word[9]);
465 for(i=0;i<strlen(word[8]);i++) {
468 imp.attr|=ATOM_ATTR_VB;
471 imp.attr|=ATOM_ATTR_HB;
474 imp.attr|=ATOM_ATTR_VA;
477 imp.attr|=ATOM_ATTR_FP;
480 imp.attr|=ATOM_ATTR_1BP;
483 imp.attr|=ATOM_ATTR_2BP;
486 imp.attr|=ATOM_ATTR_3BP;
493 imp.attr1=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_FP;
494 imp.attr2=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_FP;
495 add_stage(mdrun,STAGE_INSERT_MIXED_ATOMS,&imp);
502 else if(!strncmp(word[1],"continue",8)) {
503 cp.runs=atoi(word[2]);
504 add_stage(mdrun,STAGE_CONTINUE,&cp);
506 else if(!strncmp(word[1],"anneal",6)) {
508 ap.runs=atoi(word[2]);
510 add_stage(mdrun,STAGE_ANNEAL,&ap);
513 printf("%s unknown stage type: %s\n",
519 printf("%s unknown keyword '%s', skipped!\n",
531 int check_pressure(t_moldyn *moldyn,t_mdrun *mdrun) {
535 if(!(mdrun->sattr&SATTR_PRELAX)) {
539 delta=moldyn->p_avg-moldyn->p_ref;
550 int check_temperature(t_moldyn *moldyn,t_mdrun *mdrun) {
554 if(!(mdrun->sattr&SATTR_TRELAX))
557 delta=moldyn->t_avg-moldyn->t_ref;
568 int displace_atom(t_moldyn *moldyn,t_mdrun *mdrun) {
570 t_displace_atom_params *dap;
574 stage=mdrun->stage.current->data;
577 atom=&(moldyn->atom[dap->nr]);
585 int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
587 t_insert_atoms_params *iap;
597 stage=mdrun->stage.current->data;
602 v.x=0.0; v.y=0.0; v.z=0.0;
606 switch(mdrun->lattice) {
647 printf("%s unknown insertion mode: %02x\n",
653 while(cnt<iap->ins_atoms) {
656 if(iap->type!=INS_POS) {
657 r.x=rand_get_double(&(moldyn->random))*x;
658 r.y=rand_get_double(&(moldyn->random))*y;
659 r.z=rand_get_double(&(moldyn->random))*z;
670 if(iap->type!=INS_TOTAL) {
677 dmin=1000; // for sure too high!
678 for(i=0;i<moldyn->count;i++) {
679 atom=&(moldyn->atom[i]);
680 v3_sub(&dist,&(atom->r),&r);
681 check_per_bound(moldyn,&dist);
682 d=v3_absolute_square(&dist);
683 if(d<(iap->cr*iap->cr)) {
692 add_atom(moldyn,iap->element,pse_mass[iap->element],
693 iap->brand,iap->attr,&r,&v);
694 printf("%s atom inserted (%d/%d): %f %f %f\n",
695 ME,(iap->cnt_steps+1)*iap->ins_atoms,
696 iap->ins_steps*iap->ins_atoms,r.x,r.y,r.z);
697 printf(" -> d2 = %f/%f\n",dmin,iap->cr*iap->cr);
704 int insert_mixed_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
707 t_insert_mixed_atoms_params *imp;
709 double x,x0,y,y0,z,z0;
710 double dmin,d,cmin,cmax;
716 stage=mdrun->stage.current->data;
730 cmin=imp->crmin*imp->crmin;
731 cmax=imp->crmax*imp->crmax;
733 while(imp->amount1|imp->amount2) {
738 r.x=rand_get_double(&(moldyn->random))*x;
739 r.y=rand_get_double(&(moldyn->random))*y;
740 r.z=rand_get_double(&(moldyn->random))*z;
744 dmin=1000.0; // for sure too high!
745 for(i=0;i<moldyn->count;i++) {
746 atom=&(moldyn->atom[i]);
747 v3_sub(&dist,&(atom->r),&r);
748 check_per_bound(moldyn,&dist);
749 d=v3_absolute_square(&dist);
761 add_atom(moldyn,imp->element1,pse_mass[imp->element1],
762 imp->brand1,imp->attr1,&r,&v);
763 printf("%s (mixed) atom inserted (%d): %f %f %f\n",
764 ME,imp->amount1,r.x,r.y,r.z);
765 printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax);
772 r.x=rand_get_double(&(moldyn->random))*x;
773 r.y=rand_get_double(&(moldyn->random))*y;
774 r.z=rand_get_double(&(moldyn->random))*z;
778 dmin=1000.0; // for sure too high!
779 for(i=0;i<moldyn->count;i++) {
780 atom=&(moldyn->atom[i]);
781 v3_sub(&dist,&(atom->r),&r);
782 check_per_bound(moldyn,&dist);
783 d=v3_absolute_square(&dist);
795 add_atom(moldyn,imp->element2,pse_mass[imp->element2],
796 imp->brand2,imp->attr2,&r,&v);
797 printf("%s (mixed) atom inserted (%d): %f %f %f\n",
798 ME,imp->amount2,r.x,r.y,r.z);
799 printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax);
807 int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) {
810 t_chaattr_params *cap;
814 stage=mdrun->stage.current->data;
817 for(i=0;i<moldyn->count;i++) {
818 atom=&(moldyn->atom[i]);
819 if(cap->type&CHAATTR_ELEMENT) {
820 if(cap->element!=atom->element)
823 if(cap->type&CHAATTR_REGION) {
824 if(cap->x0<atom->r.x)
826 if(cap->y0<atom->r.y)
828 if(cap->z0<atom->r.z)
830 if(cap->x1>atom->r.x)
832 if(cap->y1>atom->r.y)
834 if(cap->z1>atom->r.z)
837 atom->attr=cap->attr;
839 printf(" atom attributes: %02x\n\n",cap->attr);
844 int chsattr(t_moldyn *moldyn,t_mdrun *mdrun) {
847 t_chsattr_params *csp;
849 stage=mdrun->stage.current->data;
852 if(csp->type&CHSATTR_PCTRL) {
854 set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
856 set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
858 if(csp->type&CHSATTR_TCTRL) {
860 set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
862 set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
864 if(csp->type&CHSATTR_PRELAX) {
866 mdrun->sattr&=(~(SATTR_PRELAX));
868 mdrun->sattr|=SATTR_PRELAX;
871 if(csp->type&CHSATTR_TRELAX) {
873 mdrun->sattr&=(~(SATTR_TRELAX));
875 mdrun->sattr|=SATTR_TRELAX;
878 if(csp->type&CHSATTR_AVGRST) {
880 mdrun->sattr|=SATTR_AVGRST;
882 mdrun->sattr&=(~(SATTR_AVGRST));
884 if(csp->type&CHSATTR_RSTEPS) {
885 mdrun->relax_steps=csp->rsteps;
891 #define stage_print(m) if(!(stage->executed)) \
894 int mdrun_hook(void *ptr1,void *ptr2) {
904 t_insert_atoms_params *iap;
905 t_insert_mixed_atoms_params *imp;
906 t_continue_params *cp;
916 /* return immediately if there are no more stage */
917 if(sl->current==NULL)
920 /* get stage description */
921 stage=sl->current->data;
923 /* default steps and tau values */
924 steps=mdrun->relax_steps;
927 /* check whether relaxation steps are necessary */
928 if((check_pressure(moldyn,mdrun)==TRUE)&\
929 (check_temperature(moldyn,mdrun)==TRUE)) {
932 stage_print("\n###########################\n");
933 stage_print("# [mdrun] executing stage #\n");
934 stage_print("###########################\n\n");
936 /* stage specific stuff */
937 switch(stage->type) {
938 case STAGE_DISPLACE_ATOM:
939 stage_print(" -> displace atom\n\n");
940 displace_atom(moldyn,mdrun);
943 case STAGE_INSERT_ATOMS:
944 stage_print(" -> insert atoms\n\n");
946 if(iap->cnt_steps==iap->ins_steps) {
950 insert_atoms(moldyn,mdrun);
956 case STAGE_INSERT_MIXED_ATOMS:
957 stage_print(" -> insert mixed atoms\n\n");
959 insert_mixed_atoms(moldyn,mdrun);
966 stage_print(" -> continue\n\n");
967 if(stage->executed==TRUE) {
975 stage_print(" -> anneal\n\n");
977 if(ap->count==ap->runs) {
981 if(moldyn->t_ref+ap->dt>=0.0)
982 set_temperature(moldyn,
983 moldyn->t_ref+ap->dt);
987 stage_print(" -> chaattr\n\n");
988 chaatr(moldyn,mdrun);
992 stage_print(" -> chsattr\n\n");
993 chsattr(moldyn,mdrun);
997 printf("%s unknwon stage type\n",ME);
1001 /* mark as executed */
1002 stage->executed=TRUE;
1005 if(change_stage==TRUE) {
1006 printf("%s finished stage\n",ME);
1007 if(list_next_f(sl)==L_NO_NEXT_ELEMENT) {
1008 printf("%s no more stages\n",ME);
1012 tau=mdrun->timestep;
1019 if(mdrun->sattr&SATTR_AVGRST)
1020 average_reset(moldyn);
1024 /* continue simulation */
1025 moldyn_add_schedule(moldyn,steps,tau);
1030 int main(int argc,char **argv) {
1037 memset(&mdrun,0,sizeof(t_mdrun));
1038 memset(&moldyn,0,sizeof(t_moldyn));
1040 /* parse arguments */
1041 if(mdrun_parse_argv(&mdrun,argc,argv)<0)
1044 /* initialize list system */
1045 list_init_f(&(mdrun.stage));
1047 /* parse config file */
1048 mdrun_parse_config(&mdrun);
1050 /* reset the stage list */
1051 list_reset_f(&(mdrun.stage));
1055 /* prepare simulation */
1057 if(mdrun.continue_file[0]) {
1058 // read the save file
1059 moldyn_read_save_file(&moldyn,mdrun.continue_file);
1060 // manualaadjusting some stuff
1063 rand_init(&(moldyn.random),NULL,1);
1064 moldyn.random.status|=RAND_STAT_VERBOSE;
1067 moldyn_init(&moldyn,argc,argv);
1070 if(set_int_alg(&moldyn,mdrun.intalgo)<0)
1074 set_cutoff(&moldyn,mdrun.cutoff);
1075 if(set_potential(&moldyn,mdrun.potential)<0)
1077 switch(mdrun.potential) {
1078 case MOLDYN_POTENTIAL_AM:
1079 albe_mult_set_params(&moldyn,
1083 case MOLDYN_POTENTIAL_TM:
1084 tersoff_mult_set_params(&moldyn,
1088 case MOLDYN_POTENTIAL_HO:
1089 harmonic_oscillator_set_params(&moldyn,mdrun.element1);
1091 case MOLDYN_POTENTIAL_LJ:
1092 lennard_jones_set_params(&moldyn,mdrun.element1);
1095 printf("%s unknown potential: %02x\n",
1096 ME,mdrun.potential);
1100 /* if it is a continue run, reset schedule and skip lattice init */
1101 if(mdrun.continue_file[0]) {
1102 memset(&(moldyn.schedule),0,sizeof(t_moldyn_schedule));
1106 /* initial lattice and dimensions */
1107 set_dim(&moldyn,mdrun.dim.x,mdrun.dim.y,mdrun.dim.z,mdrun.vis);
1108 set_pbc(&moldyn,mdrun.pbcx,mdrun.pbcy,mdrun.pbcz);
1109 switch(mdrun.lattice) {
1111 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
1112 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1113 mdrun.ly,mdrun.lz,NULL);
1116 create_lattice(&moldyn,DIAMOND,mdrun.lc,mdrun.element1,
1117 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1118 mdrun.ly,mdrun.lz,NULL);
1121 o.x=0.5*0.25*mdrun.lc; o.y=o.x; o.z=o.x;
1122 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
1123 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1124 mdrun.ly,mdrun.lz,&o);
1125 o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x;
1126 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2,
1127 mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx,
1128 mdrun.ly,mdrun.lz,&o);
1131 set_nn_dist(&moldyn,mdrun.nnd);
1134 printf("%s unknown lattice type: %02x\n",
1138 moldyn_bc_check(&moldyn);
1140 /* temperature and pressure */
1141 set_temperature(&moldyn,mdrun.temperature);
1142 set_pressure(&moldyn,mdrun.pressure);
1143 thermal_init(&moldyn,TRUE);
1146 /* first schedule */
1147 moldyn_add_schedule(&moldyn,mdrun.prerun,mdrun.timestep);
1150 moldyn_set_log_dir(&moldyn,mdrun.sdir);
1151 moldyn_set_report(&moldyn,"CHANGE ME","CHANGE ME TOO");
1153 moldyn_set_log(&moldyn,LOG_TOTAL_ENERGY,mdrun.elog);
1155 moldyn_set_log(&moldyn,LOG_TEMPERATURE,mdrun.tlog);
1157 moldyn_set_log(&moldyn,LOG_PRESSURE,mdrun.plog);
1159 moldyn_set_log(&moldyn,LOG_VOLUME,mdrun.vlog);
1161 moldyn_set_log(&moldyn,VISUAL_STEP,mdrun.visualize);
1163 moldyn_set_log(&moldyn,SAVE_STEP,mdrun.save);
1164 moldyn_set_log(&moldyn,CREATE_REPORT,0);
1165 set_avg_skip(&moldyn,mdrun.avgskip);
1167 /* prepare the hook function */
1168 moldyn_set_schedule_hook(&moldyn,&mdrun_hook,&mdrun);
1170 /* run the simulation */
1171 moldyn_integrate(&moldyn);
1174 moldyn_shutdown(&moldyn);
1176 list_destroy_f(&(mdrun.stage));