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 psize=sizeof(t_set_temp_params);
117 case STAGE_SET_TIMESTEP:
118 psize=sizeof(t_set_timestep_params);
121 printf("%s unknown stage type: %02x\n",ME,type);
125 stage=malloc(sizeof(t_stage));
127 perror("[mdrun] malloc (add stage)");
132 stage->executed=FALSE;
134 stage->params=malloc(psize);
135 if(stage->params==NULL) {
136 perror("[mdrun] malloc (stage params)");
140 memcpy(stage->params,params,psize);
142 list_add_immediate_f(&(mdrun->stage),stage);
147 int mdrun_parse_config(t_mdrun *mdrun) {
157 t_displace_atom_params dap;
158 t_insert_atoms_params iap;
159 t_insert_mixed_atoms_params imp;
160 t_continue_params cp;
162 t_chaattr_params cap;
163 t_chsattr_params csp;
164 t_set_temp_params stp;
165 t_set_timestep_params stsp;
167 /* open config file */
168 fd=open(mdrun->cfile,O_RDONLY);
170 snprintf(error,128,"%s open cfile %s",ME,mdrun->cfile);
175 /* read, parse, set */
180 ret=get_line(fd,line,128);
184 // ignore # lines and \n
185 if((line[0]=='#')|(ret==1))
189 memset(&iap,0,sizeof(t_insert_atoms_params));
190 memset(&imp,0,sizeof(t_insert_mixed_atoms_params));
191 memset(&cp,0,sizeof(t_continue_params));
192 memset(&ap,0,sizeof(t_anneal_params));
193 memset(&cap,0,sizeof(t_chaattr_params));
194 memset(&csp,0,sizeof(t_chsattr_params));
195 memset(&stp,0,sizeof(t_set_temp_params));
196 memset(&stsp,0,sizeof(t_set_timestep_params));
198 // get command + args
202 wptr=strtok(NULL," \t");
204 wptr=strtok(line," \t");
207 strncpy(word[wcnt],wptr,64);
211 if(!strncmp(word[0],"potential",9)) {
212 if(!strncmp(word[1],"albe",4))
213 mdrun->potential=MOLDYN_POTENTIAL_AM;
214 if(!strncmp(word[1],"tersoff",7))
215 mdrun->potential=MOLDYN_POTENTIAL_TM;
216 if(!strncmp(word[1],"ho",2))
217 mdrun->potential=MOLDYN_POTENTIAL_HO;
218 if(!strncmp(word[1],"lj",2))
219 mdrun->potential=MOLDYN_POTENTIAL_LJ;
221 else if(!strncmp(word[0],"continue",8))
222 strncpy(mdrun->continue_file,word[1],128);
223 else if(!strncmp(word[0],"cutoff",6))
224 mdrun->cutoff=atof(word[1]);
225 else if(!strncmp(word[0],"nnd",3))
226 mdrun->nnd=atof(word[1]);
227 else if(!strncmp(word[0],"intalgo",7)) {
228 if(!strncmp(word[1],"verlet",5))
229 mdrun->intalgo=MOLDYN_INTEGRATE_VERLET;
231 else if(!strncmp(word[0],"timestep",8))
232 mdrun->timestep=atof(word[1]);
233 else if(!strncmp(word[0],"volume",6)) {
234 mdrun->dim.x=atof(word[1]);
235 mdrun->dim.y=atof(word[2]);
236 mdrun->dim.z=atof(word[3]);
237 if(strncmp(word[4],"0",1))
240 else if(!strncmp(word[0],"pbc",3)) {
241 if(strncmp(word[1],"0",1))
245 if(strncmp(word[2],"0",1))
249 if(strncmp(word[3],"0",1))
254 else if(!strncmp(word[0],"temperature",11))
255 mdrun->temperature=atof(word[1]);
256 else if(!strncmp(word[0],"pressure",8))
257 mdrun->pressure=atof(word[1]);
258 else if(!strncmp(word[0],"lattice",7)) {
259 if(!strncmp(word[1],"zincblende",10))
260 mdrun->lattice=ZINCBLENDE;
261 if(!strncmp(word[1],"fcc",3))
263 if(!strncmp(word[1],"diamond",7))
264 mdrun->lattice=DIAMOND;
265 if(!strncmp(word[1],"none",4))
268 else if(!strncmp(word[0],"element1",8)) {
269 mdrun->element1=atoi(word[1]);
270 mdrun->m1=pse_mass[mdrun->element1];
272 else if(!strncmp(word[0],"element2",8)) {
273 mdrun->element2=atoi(word[1]);
274 mdrun->m2=pse_mass[mdrun->element2];
276 else if(!strncmp(word[0],"fill",6)) {
277 // only lc mode by now
278 mdrun->lx=atoi(word[2]);
279 mdrun->ly=atoi(word[3]);
280 mdrun->lz=atoi(word[4]);
281 mdrun->lc=atof(word[5]);
283 else if(!strncmp(word[0],"aattr",5)) {
284 // for aatrib line we need a special stage
285 // containing one schedule of 0 loops ...
286 for(i=0;i<strlen(word[1]);i++) {
289 cap.type|=CHAATTR_TOTALV;
292 cap.type|=CHAATTR_REGION;
295 cap.type|=CHAATTR_ELEMENT;
302 if(cap.type&CHAATTR_REGION) {
303 cap.x0=atof(word[1]);
304 cap.y0=atof(word[2]);
305 cap.z0=atof(word[3]);
306 cap.x1=atof(word[4]);
307 cap.y1=atof(word[5]);
308 cap.z1=atof(word[6]);
311 if(cap.type&CHAATTR_ELEMENT) {
312 cap.element=atoi(word[i]);
315 for(o=0;o<strlen(word[i]);o++) {
318 cap.attr|=ATOM_ATTR_VB;
321 cap.attr|=ATOM_ATTR_HB;
324 cap.attr|=ATOM_ATTR_VA;
327 cap.attr|=ATOM_ATTR_FP;
330 cap.attr|=ATOM_ATTR_1BP;
333 cap.attr|=ATOM_ATTR_2BP;
336 cap.attr|=ATOM_ATTR_3BP;
342 add_stage(mdrun,STAGE_CHAATTR,&cap);
344 else if(!strncmp(word[0],"sattr",5)) {
345 // for satrib line we need a special stage
346 // containing one schedule of 0 loops ...
348 for(i=1;i<wcnt;i++) {
349 if(!strncmp(word[i],"pctrl",5)) {
350 csp.ptau=0.01/(atof(word[++i])*GPA);
351 csp.type|=CHSATTR_PCTRL;
353 if(!strncmp(word[i],"tctrl",5)) {
354 csp.ttau=atof(word[++i]);
355 csp.type|=CHSATTR_TCTRL;
357 if(!strncmp(word[i],"prelax",6)) {
358 csp.dp=atof(word[++i])*BAR;
359 csp.type|=CHSATTR_PRELAX;
361 if(!strncmp(word[i],"trelax",6)) {
362 csp.dt=atof(word[++i]);
363 csp.type|=CHSATTR_TRELAX;
365 if(!strncmp(word[i],"rsteps",6)) {
366 csp.rsteps=atoi(word[++i]);
367 csp.type|=CHSATTR_RSTEPS;
369 if(!strncmp(word[i],"avgrst",6)) {
370 csp.avgrst=atoi(word[++i]);
371 csp.type|=CHSATTR_AVGRST;
374 add_stage(mdrun,STAGE_CHSATTR,&csp);
376 else if(!strncmp(word[0],"prerun",6))
377 mdrun->prerun=atoi(word[1]);
378 else if(!strncmp(word[0],"avgskip",7))
379 mdrun->avgskip=atoi(word[1]);
380 else if(!strncmp(word[0],"elog",4))
381 mdrun->elog=atoi(word[1]);
382 else if(!strncmp(word[0],"tlog",4))
383 mdrun->tlog=atoi(word[1]);
384 else if(!strncmp(word[0],"plog",4))
385 mdrun->plog=atoi(word[1]);
386 else if(!strncmp(word[0],"vlog",4))
387 mdrun->vlog=atoi(word[1]);
388 else if(!strncmp(word[0],"save",4))
389 mdrun->save=atoi(word[1]);
390 else if(!strncmp(word[0],"visualize",9))
391 mdrun->visualize=atoi(word[1]);
392 else if(!strncmp(word[0],"stage",5)) {
393 // for every stage line, add a stage
394 if(!strncmp(word[1],"displace",8)) {
395 dap.nr=atoi(word[2]);
396 dap.dx=atof(word[3]);
397 dap.dy=atof(word[4]);
398 dap.dz=atof(word[5]);
399 add_stage(mdrun,STAGE_DISPLACE_ATOM,&dap);
401 else if(!strncmp(word[1],"ins_atoms",9)) {
402 iap.ins_steps=atoi(word[2]);
403 iap.ins_atoms=atoi(word[3]);
404 iap.element=atoi(word[4]);
405 iap.brand=atoi(word[5]);
406 for(i=0;i<strlen(word[6]);i++) {
409 iap.attr|=ATOM_ATTR_VB;
412 iap.attr|=ATOM_ATTR_HB;
415 iap.attr|=ATOM_ATTR_VA;
418 iap.attr|=ATOM_ATTR_FP;
421 iap.attr|=ATOM_ATTR_1BP;
424 iap.attr|=ATOM_ATTR_2BP;
427 iap.attr|=ATOM_ATTR_3BP;
437 iap.x0=atof(word[8]);
438 iap.y0=atof(word[9]);
439 iap.z0=atof(word[10]);
442 if(word[8][0]=='t') {
444 iap.cr=atof(word[9]);
448 iap.x0=atof(word[8]);
449 iap.y0=atof(word[9]);
450 iap.z0=atof(word[10]);
451 iap.x1=atof(word[11]);
452 iap.y1=atof(word[12]);
453 iap.z1=atof(word[13]);
454 iap.cr=atof(word[14]);
459 add_stage(mdrun,STAGE_INSERT_ATOMS,&iap);
465 else if(!strncmp(word[1],"ins_m_atoms",11)) {
466 imp.element1=atoi(word[2]);
467 imp.element2=atoi(word[3]);
468 imp.amount1=atoi(word[4]);
469 imp.amount2=atoi(word[5]);
470 imp.brand1=atoi(word[6]);
471 imp.brand2=atoi(word[7]);
472 imp.crmin=atof(word[8]);
473 imp.crmax=atof(word[9]);
475 for(i=0;i<strlen(word[8]);i++) {
478 imp.attr|=ATOM_ATTR_VB;
481 imp.attr|=ATOM_ATTR_HB;
484 imp.attr|=ATOM_ATTR_VA;
487 imp.attr|=ATOM_ATTR_FP;
490 imp.attr|=ATOM_ATTR_1BP;
493 imp.attr|=ATOM_ATTR_2BP;
496 imp.attr|=ATOM_ATTR_3BP;
503 imp.attr1=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_FP;
504 imp.attr2=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_FP;
505 add_stage(mdrun,STAGE_INSERT_MIXED_ATOMS,&imp);
512 else if(!strncmp(word[1],"continue",8)) {
513 cp.runs=atoi(word[2]);
514 add_stage(mdrun,STAGE_CONTINUE,&cp);
516 else if(!strncmp(word[1],"anneal",6)) {
518 ap.runs=atoi(word[2]);
520 ap.interval=atoi(word[4]);
521 add_stage(mdrun,STAGE_ANNEAL,&ap);
523 else if(!strncmp(word[1],"set_temp",8)) {
524 if(word[2][0]=='c') {
525 stp.type=SET_TEMP_CURRENT;
529 stp.type=SET_TEMP_VALUE;
530 stp.val=atof(word[2]);
532 add_stage(mdrun,STAGE_SET_TEMP,&stp);
534 else if(!strncmp(word[1],"set_timestep",12)) {
535 stsp.tau=atof(word[2]);
536 add_stage(mdrun,STAGE_SET_TIMESTEP,&stsp);
539 printf("%s unknown stage type: %s\n",
545 printf("%s unknown keyword '%s', skipped!\n",
557 int check_pressure(t_moldyn *moldyn,t_mdrun *mdrun) {
561 if(!(mdrun->sattr&SATTR_PRELAX)) {
565 delta=moldyn->p_avg-moldyn->p_ref;
576 int check_temperature(t_moldyn *moldyn,t_mdrun *mdrun) {
580 if(!(mdrun->sattr&SATTR_TRELAX))
583 delta=moldyn->t_avg-moldyn->t_ref;
594 int displace_atom(t_moldyn *moldyn,t_mdrun *mdrun) {
596 t_displace_atom_params *dap;
600 stage=mdrun->stage.current->data;
603 atom=&(moldyn->atom[dap->nr]);
611 int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
613 t_insert_atoms_params *iap;
623 stage=mdrun->stage.current->data;
628 v.x=0.0; v.y=0.0; v.z=0.0;
632 switch(mdrun->lattice) {
673 printf("%s unknown insertion mode: %02x\n",
679 while(cnt<iap->ins_atoms) {
682 if(iap->type!=INS_POS) {
683 r.x=rand_get_double(&(moldyn->random))*x;
684 r.y=rand_get_double(&(moldyn->random))*y;
685 r.z=rand_get_double(&(moldyn->random))*z;
696 if(iap->type!=INS_TOTAL) {
703 dmin=1000; // for sure too high!
704 for(i=0;i<moldyn->count;i++) {
705 atom=&(moldyn->atom[i]);
706 v3_sub(&dist,&(atom->r),&r);
707 check_per_bound(moldyn,&dist);
708 d=v3_absolute_square(&dist);
709 if(d<(iap->cr*iap->cr)) {
718 add_atom(moldyn,iap->element,pse_mass[iap->element],
719 iap->brand,iap->attr,&r,&v);
720 printf("%s atom inserted (%d/%d): %f %f %f\n",
721 ME,(iap->cnt_steps+1)*iap->ins_atoms,
722 iap->ins_steps*iap->ins_atoms,r.x,r.y,r.z);
723 printf(" -> d2 = %f/%f\n",dmin,iap->cr*iap->cr);
730 int insert_mixed_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
733 t_insert_mixed_atoms_params *imp;
735 double x,x0,y,y0,z,z0;
736 double dmin,d,cmin,cmax;
742 stage=mdrun->stage.current->data;
756 cmin=imp->crmin*imp->crmin;
757 cmax=imp->crmax*imp->crmax;
759 while(imp->amount1|imp->amount2) {
764 r.x=rand_get_double(&(moldyn->random))*x;
765 r.y=rand_get_double(&(moldyn->random))*y;
766 r.z=rand_get_double(&(moldyn->random))*z;
770 dmin=1000.0; // for sure too high!
771 for(i=0;i<moldyn->count;i++) {
772 atom=&(moldyn->atom[i]);
773 v3_sub(&dist,&(atom->r),&r);
774 check_per_bound(moldyn,&dist);
775 d=v3_absolute_square(&dist);
787 add_atom(moldyn,imp->element1,pse_mass[imp->element1],
788 imp->brand1,imp->attr1,&r,&v);
789 printf("%s (mixed) atom inserted (%d): %f %f %f\n",
790 ME,imp->amount1,r.x,r.y,r.z);
791 printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax);
798 r.x=rand_get_double(&(moldyn->random))*x;
799 r.y=rand_get_double(&(moldyn->random))*y;
800 r.z=rand_get_double(&(moldyn->random))*z;
804 dmin=1000.0; // for sure too high!
805 for(i=0;i<moldyn->count;i++) {
806 atom=&(moldyn->atom[i]);
807 v3_sub(&dist,&(atom->r),&r);
808 check_per_bound(moldyn,&dist);
809 d=v3_absolute_square(&dist);
821 add_atom(moldyn,imp->element2,pse_mass[imp->element2],
822 imp->brand2,imp->attr2,&r,&v);
823 printf("%s (mixed) atom inserted (%d): %f %f %f\n",
824 ME,imp->amount2,r.x,r.y,r.z);
825 printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax);
833 int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) {
836 t_chaattr_params *cap;
840 stage=mdrun->stage.current->data;
843 for(i=0;i<moldyn->count;i++) {
844 atom=&(moldyn->atom[i]);
845 if(cap->type&CHAATTR_ELEMENT) {
846 if(cap->element!=atom->element)
849 if(cap->type&CHAATTR_REGION) {
850 if(cap->x0<atom->r.x)
852 if(cap->y0<atom->r.y)
854 if(cap->z0<atom->r.z)
856 if(cap->x1>atom->r.x)
858 if(cap->y1>atom->r.y)
860 if(cap->z1>atom->r.z)
863 atom->attr=cap->attr;
869 int chsattr(t_moldyn *moldyn,t_mdrun *mdrun) {
872 t_chsattr_params *csp;
874 stage=mdrun->stage.current->data;
877 if(csp->type&CHSATTR_PCTRL) {
879 set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
881 set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
883 if(csp->type&CHSATTR_TCTRL) {
885 set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
887 set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
889 if(csp->type&CHSATTR_PRELAX) {
891 mdrun->sattr&=(~(SATTR_PRELAX));
893 mdrun->sattr|=SATTR_PRELAX;
896 if(csp->type&CHSATTR_TRELAX) {
898 mdrun->sattr&=(~(SATTR_TRELAX));
900 mdrun->sattr|=SATTR_TRELAX;
903 if(csp->type&CHSATTR_AVGRST) {
905 mdrun->sattr|=SATTR_AVGRST;
907 mdrun->sattr&=(~(SATTR_AVGRST));
909 if(csp->type&CHSATTR_RSTEPS) {
910 mdrun->relax_steps=csp->rsteps;
916 #define stage_print(m) if(!(stage->executed)) \
919 int mdrun_hook(void *ptr1,void *ptr2) {
928 t_insert_atoms_params *iap;
929 t_insert_mixed_atoms_params *imp;
930 t_continue_params *cp;
932 t_set_temp_params *stp;
933 t_set_timestep_params *stsp;
942 /* return immediately if there are no more stage */
943 if(sl->current==NULL)
946 /* get stage description */
947 stage=sl->current->data;
949 /* steps in next schedule */
950 steps=mdrun->relax_steps;
952 /* check whether relaxation steps are necessary */
953 if((check_pressure(moldyn,mdrun)==TRUE)&\
954 (check_temperature(moldyn,mdrun)==TRUE)) {
957 stage_print("\n###########################\n");
958 stage_print("# [mdrun] executing stage #\n");
959 stage_print("###########################\n\n");
961 /* stage specific stuff */
962 switch(stage->type) {
963 case STAGE_DISPLACE_ATOM:
964 stage_print(" -> displace atom\n\n");
965 displace_atom(moldyn,mdrun);
968 case STAGE_INSERT_ATOMS:
969 stage_print(" -> insert atoms\n\n");
971 if(iap->cnt_steps==iap->ins_steps) {
975 insert_atoms(moldyn,mdrun);
981 case STAGE_INSERT_MIXED_ATOMS:
982 stage_print(" -> insert mixed atoms\n\n");
984 insert_mixed_atoms(moldyn,mdrun);
991 stage_print(" -> continue\n\n");
992 if(stage->executed==TRUE) {
1000 stage_print(" -> anneal\n\n");
1002 if(ap->count==ap->runs) {
1006 if(moldyn->t_ref+ap->dt>=0.0)
1007 set_temperature(moldyn,
1008 moldyn->t_ref+ap->dt);
1013 stage_print(" -> change atom attributes\n\n");
1014 chaatr(moldyn,mdrun);
1018 stage_print(" -> change sys attributes\n\n");
1019 chsattr(moldyn,mdrun);
1022 case STAGE_SET_TEMP:
1023 stage_print(" -> set temperature\n\n");
1025 if(stp->type&SET_TEMP_CURRENT) {
1026 set_temperature(moldyn,moldyn->t_avg);
1029 set_temperature(moldyn,stp->val);
1033 case STAGE_SET_TIMESTEP:
1034 stage_print(" -> set timestep\n\n");
1036 mdrun->timestep=stsp->tau;
1040 printf("%s unknwon stage type\n",ME);
1044 /* mark as executed */
1045 stage->executed=TRUE;
1048 if(change_stage==TRUE) {
1049 printf("%s finished stage\n",ME);
1050 if(list_next_f(sl)==L_NO_NEXT_ELEMENT) {
1051 printf("%s no more stages\n",ME);
1061 if(mdrun->sattr&SATTR_AVGRST)
1062 average_reset(moldyn);
1066 /* continue simulation */
1067 moldyn_add_schedule(moldyn,steps,mdrun->timestep);
1072 int main(int argc,char **argv) {
1079 memset(&mdrun,0,sizeof(t_mdrun));
1080 memset(&moldyn,0,sizeof(t_moldyn));
1082 /* parse arguments */
1083 if(mdrun_parse_argv(&mdrun,argc,argv)<0)
1086 /* initialize list system */
1087 list_init_f(&(mdrun.stage));
1089 /* parse config file */
1090 mdrun_parse_config(&mdrun);
1092 /* reset the stage list */
1093 list_reset_f(&(mdrun.stage));
1097 /* prepare simulation */
1099 if(mdrun.continue_file[0]) {
1100 // read the save file
1101 moldyn_read_save_file(&moldyn,mdrun.continue_file);
1102 // manualaadjusting some stuff
1105 rand_init(&(moldyn.random),NULL,1);
1106 moldyn.random.status|=RAND_STAT_VERBOSE;
1109 moldyn_init(&moldyn,argc,argv);
1112 if(set_int_alg(&moldyn,mdrun.intalgo)<0)
1116 set_cutoff(&moldyn,mdrun.cutoff);
1117 if(set_potential(&moldyn,mdrun.potential)<0)
1119 switch(mdrun.potential) {
1120 case MOLDYN_POTENTIAL_AM:
1121 albe_mult_set_params(&moldyn,
1125 case MOLDYN_POTENTIAL_TM:
1126 tersoff_mult_set_params(&moldyn,
1130 case MOLDYN_POTENTIAL_HO:
1131 harmonic_oscillator_set_params(&moldyn,mdrun.element1);
1133 case MOLDYN_POTENTIAL_LJ:
1134 lennard_jones_set_params(&moldyn,mdrun.element1);
1137 printf("%s unknown potential: %02x\n",
1138 ME,mdrun.potential);
1142 /* if it is a continue run, reset schedule and skip lattice init */
1143 if(mdrun.continue_file[0]) {
1144 memset(&(moldyn.schedule),0,sizeof(t_moldyn_schedule));
1148 /* initial lattice and dimensions */
1149 set_dim(&moldyn,mdrun.dim.x,mdrun.dim.y,mdrun.dim.z,mdrun.vis);
1150 set_pbc(&moldyn,mdrun.pbcx,mdrun.pbcy,mdrun.pbcz);
1151 switch(mdrun.lattice) {
1153 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
1154 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1155 mdrun.ly,mdrun.lz,NULL);
1158 create_lattice(&moldyn,DIAMOND,mdrun.lc,mdrun.element1,
1159 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1160 mdrun.ly,mdrun.lz,NULL);
1163 o.x=0.5*0.25*mdrun.lc; o.y=o.x; o.z=o.x;
1164 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
1165 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1166 mdrun.ly,mdrun.lz,&o);
1167 o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x;
1168 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2,
1169 mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx,
1170 mdrun.ly,mdrun.lz,&o);
1173 set_nn_dist(&moldyn,mdrun.nnd);
1176 printf("%s unknown lattice type: %02x\n",
1180 moldyn_bc_check(&moldyn);
1182 /* temperature and pressure */
1183 set_temperature(&moldyn,mdrun.temperature);
1184 set_pressure(&moldyn,mdrun.pressure);
1185 thermal_init(&moldyn,TRUE);
1188 /* first schedule */
1189 moldyn_add_schedule(&moldyn,mdrun.prerun,mdrun.timestep);
1192 moldyn_set_log_dir(&moldyn,mdrun.sdir);
1193 moldyn_set_report(&moldyn,"CHANGE ME","CHANGE ME TOO");
1195 moldyn_set_log(&moldyn,LOG_TOTAL_ENERGY,mdrun.elog);
1197 moldyn_set_log(&moldyn,LOG_TEMPERATURE,mdrun.tlog);
1199 moldyn_set_log(&moldyn,LOG_PRESSURE,mdrun.plog);
1201 moldyn_set_log(&moldyn,LOG_VOLUME,mdrun.vlog);
1203 moldyn_set_log(&moldyn,VISUAL_STEP,mdrun.visualize);
1205 moldyn_set_log(&moldyn,SAVE_STEP,mdrun.save);
1206 moldyn_set_log(&moldyn,CREATE_REPORT,0);
1207 set_avg_skip(&moldyn,mdrun.avgskip);
1209 /* prepare the hook function */
1210 moldyn_set_schedule_hook(&moldyn,&mdrun_hook,&mdrun);
1212 /* run the simulation */
1213 moldyn_integrate(&moldyn);
1216 moldyn_shutdown(&moldyn);
1218 list_destroy_f(&(mdrun.stage));