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"
31 int mdrun_usage(void) {
33 printf("%s usage:\n",ME);
38 int mdrun_parse_argv(t_mdrun *mdrun,int argc,char **argv) {
45 printf("%s unknown switch: %s\n",ME,argv[i]);
51 strncpy(mdrun->cfile,argv[++i],128);
54 strncpy(mdrun->sdir,argv[++i],128);
60 printf("%s unknown option: %s\n",ME,argv[i]);
70 int del_stages(t_mdrun *mdrun) {
83 stage=sl->current->data;
86 } while(list_next_f(sl)!=L_NO_NEXT_ELEMENT);
91 int add_stage(t_mdrun *mdrun,u8 type,void *params) {
98 case STAGE_DISPLACE_ATOM:
99 psize=sizeof(t_displace_atom_params);
101 case STAGE_INSERT_ATOMS:
102 psize=sizeof(t_insert_atoms_params);
104 case STAGE_INSERT_MIXED_ATOMS:
105 psize=sizeof(t_insert_mixed_atoms_params);
108 psize=sizeof(t_continue_params);
111 psize=sizeof(t_anneal_params);
114 psize=sizeof(t_chaattr_params);
117 psize=sizeof(t_chsattr_params);
120 psize=sizeof(t_set_temp_params);
122 case STAGE_SET_TIMESTEP:
123 psize=sizeof(t_set_timestep_params);
126 printf("%s unknown stage type: %02x\n",ME,type);
130 stage=malloc(sizeof(t_stage));
132 perror("[mdrun] malloc (add stage)");
137 stage->executed=FALSE;
139 stage->params=malloc(psize);
140 if(stage->params==NULL) {
141 perror("[mdrun] malloc (stage params)");
145 memcpy(stage->params,params,psize);
147 list_add_immediate_f(&(mdrun->stage),stage);
152 int mdrun_parse_config(t_mdrun *mdrun) {
162 t_displace_atom_params dap;
163 t_insert_atoms_params iap;
164 t_insert_mixed_atoms_params imp;
165 t_continue_params cp;
167 t_chaattr_params cap;
168 t_chsattr_params csp;
169 t_set_temp_params stp;
170 t_set_timestep_params stsp;
172 /* open config file */
173 fd=open(mdrun->cfile,O_RDONLY);
175 snprintf(error,128,"%s open cfile %s",ME,mdrun->cfile);
180 /* read, parse, set */
185 ret=get_line(fd,line,128);
189 // ignore # lines and \n
190 if((line[0]=='#')|(ret==1))
194 memset(&iap,0,sizeof(t_insert_atoms_params));
195 memset(&imp,0,sizeof(t_insert_mixed_atoms_params));
196 memset(&cp,0,sizeof(t_continue_params));
197 memset(&ap,0,sizeof(t_anneal_params));
198 memset(&cap,0,sizeof(t_chaattr_params));
199 memset(&csp,0,sizeof(t_chsattr_params));
200 memset(&stp,0,sizeof(t_set_temp_params));
201 memset(&stsp,0,sizeof(t_set_timestep_params));
203 // get command + args
207 wptr=strtok(NULL," \t");
209 wptr=strtok(line," \t");
212 strncpy(word[wcnt],wptr,64);
216 if(!strncmp(word[0],"potential",9)) {
217 if(!strncmp(word[1],"albe",4))
218 mdrun->potential=MOLDYN_POTENTIAL_AM;
219 if(!strncmp(word[1],"tersoff",7))
220 mdrun->potential=MOLDYN_POTENTIAL_TM;
221 if(!strncmp(word[1],"ho",2))
222 mdrun->potential=MOLDYN_POTENTIAL_HO;
223 if(!strncmp(word[1],"lj",2))
224 mdrun->potential=MOLDYN_POTENTIAL_LJ;
226 else if(!strncmp(word[0],"continue",8))
227 strncpy(mdrun->continue_file,word[1],128);
228 else if(!strncmp(word[0],"cutoff",6))
229 mdrun->cutoff=atof(word[1]);
230 else if(!strncmp(word[0],"nnd",3))
231 mdrun->nnd=atof(word[1]);
232 else if(!strncmp(word[0],"intalgo",7)) {
233 if(!strncmp(word[1],"verlet",5))
234 mdrun->intalgo=MOLDYN_INTEGRATE_VERLET;
236 else if(!strncmp(word[0],"timestep",8))
237 mdrun->timestep=atof(word[1]);
238 else if(!strncmp(word[0],"volume",6)) {
239 mdrun->dim.x=atof(word[1]);
240 mdrun->dim.y=atof(word[2]);
241 mdrun->dim.z=atof(word[3]);
242 if(strncmp(word[4],"0",1))
245 else if(!strncmp(word[0],"pbc",3)) {
246 if(strncmp(word[1],"0",1))
250 if(strncmp(word[2],"0",1))
254 if(strncmp(word[3],"0",1))
259 else if(!strncmp(word[0],"temperature",11))
260 mdrun->temperature=atof(word[1]);
261 else if(!strncmp(word[0],"pressure",8))
262 mdrun->pressure=atof(word[1]);
263 else if(!strncmp(word[0],"lattice",7)) {
264 if(!strncmp(word[1],"zincblende",10))
265 mdrun->lattice=ZINCBLENDE;
266 if(!strncmp(word[1],"fcc",3))
268 if(!strncmp(word[1],"diamond",7))
269 mdrun->lattice=DIAMOND;
270 if(!strncmp(word[1],"none",4))
273 else if(!strncmp(word[0],"element1",8)) {
274 mdrun->element1=atoi(word[1]);
275 mdrun->m1=pse_mass[mdrun->element1];
277 else if(!strncmp(word[0],"element2",8)) {
278 mdrun->element2=atoi(word[1]);
279 mdrun->m2=pse_mass[mdrun->element2];
281 else if(!strncmp(word[0],"fill",6)) {
282 // only lc mode by now
283 mdrun->lx=atoi(word[2]);
284 mdrun->ly=atoi(word[3]);
285 mdrun->lz=atoi(word[4]);
286 mdrun->lc=atof(word[5]);
288 else if(!strncmp(word[0],"aattr",5)) {
289 // for aatrib line we need a special stage
290 // containing one schedule of 0 loops ...
291 for(i=0;i<strlen(word[1]);i++) {
294 cap.type|=CHAATTR_TOTALV;
297 cap.type|=CHAATTR_REGION;
300 cap.type|=CHAATTR_ELEMENT;
307 if(cap.type&CHAATTR_REGION) {
308 cap.x0=atof(word[1]);
309 cap.y0=atof(word[2]);
310 cap.z0=atof(word[3]);
311 cap.x1=atof(word[4]);
312 cap.y1=atof(word[5]);
313 cap.z1=atof(word[6]);
316 if(cap.type&CHAATTR_ELEMENT) {
317 cap.element=atoi(word[i]);
320 for(o=0;o<strlen(word[i]);o++) {
323 cap.attr|=ATOM_ATTR_VB;
326 cap.attr|=ATOM_ATTR_HB;
329 cap.attr|=ATOM_ATTR_VA;
332 cap.attr|=ATOM_ATTR_FP;
335 cap.attr|=ATOM_ATTR_1BP;
338 cap.attr|=ATOM_ATTR_2BP;
341 cap.attr|=ATOM_ATTR_3BP;
347 add_stage(mdrun,STAGE_CHAATTR,&cap);
349 else if(!strncmp(word[0],"sattr",5)) {
350 // for satrib line we need a special stage
351 // containing one schedule of 0 loops ...
353 for(i=1;i<wcnt;i++) {
354 if(!strncmp(word[i],"pctrl",5)) {
355 csp.ptau=0.01/(atof(word[++i])*GPA);
356 csp.type|=CHSATTR_PCTRL;
358 if(!strncmp(word[i],"tctrl",5)) {
359 csp.ttau=atof(word[++i]);
360 csp.type|=CHSATTR_TCTRL;
362 if(!strncmp(word[i],"prelax",6)) {
363 csp.dp=atof(word[++i])*BAR;
364 csp.type|=CHSATTR_PRELAX;
366 if(!strncmp(word[i],"trelax",6)) {
367 csp.dt=atof(word[++i]);
368 csp.type|=CHSATTR_TRELAX;
370 if(!strncmp(word[i],"rsteps",6)) {
371 csp.rsteps=atoi(word[++i]);
372 csp.type|=CHSATTR_RSTEPS;
374 if(!strncmp(word[i],"avgrst",6)) {
375 csp.avgrst=atoi(word[++i]);
376 csp.type|=CHSATTR_AVGRST;
379 add_stage(mdrun,STAGE_CHSATTR,&csp);
381 else if(!strncmp(word[0],"prerun",6))
382 mdrun->prerun=atoi(word[1]);
383 else if(!strncmp(word[0],"avgskip",7))
384 mdrun->avgskip=atoi(word[1]);
385 else if(!strncmp(word[0],"elog",4))
386 mdrun->elog=atoi(word[1]);
387 else if(!strncmp(word[0],"tlog",4))
388 mdrun->tlog=atoi(word[1]);
389 else if(!strncmp(word[0],"plog",4))
390 mdrun->plog=atoi(word[1]);
391 else if(!strncmp(word[0],"vlog",4))
392 mdrun->vlog=atoi(word[1]);
393 else if(!strncmp(word[0],"save",4))
394 mdrun->save=atoi(word[1]);
395 else if(!strncmp(word[0],"visualize",9))
396 mdrun->visualize=atoi(word[1]);
397 else if(!strncmp(word[0],"stage",5)) {
398 // for every stage line, add a stage
399 if(!strncmp(word[1],"displace",8)) {
400 dap.nr=atoi(word[2]);
401 dap.dx=atof(word[3]);
402 dap.dy=atof(word[4]);
403 dap.dz=atof(word[5]);
404 add_stage(mdrun,STAGE_DISPLACE_ATOM,&dap);
406 else if(!strncmp(word[1],"ins_atoms",9)) {
407 iap.ins_steps=atoi(word[2]);
408 iap.ins_atoms=atoi(word[3]);
409 iap.element=atoi(word[4]);
410 iap.brand=atoi(word[5]);
411 for(i=0;i<strlen(word[6]);i++) {
414 iap.attr|=ATOM_ATTR_VB;
417 iap.attr|=ATOM_ATTR_HB;
420 iap.attr|=ATOM_ATTR_VA;
423 iap.attr|=ATOM_ATTR_FP;
426 iap.attr|=ATOM_ATTR_1BP;
429 iap.attr|=ATOM_ATTR_2BP;
432 iap.attr|=ATOM_ATTR_3BP;
442 iap.x0=atof(word[8]);
443 iap.y0=atof(word[9]);
444 iap.z0=atof(word[10]);
447 if(word[8][0]=='t') {
449 iap.cr=atof(word[9]);
453 iap.x0=atof(word[8]);
454 iap.y0=atof(word[9]);
455 iap.z0=atof(word[10]);
456 iap.x1=atof(word[11]);
457 iap.y1=atof(word[12]);
458 iap.z1=atof(word[13]);
459 iap.cr=atof(word[14]);
464 add_stage(mdrun,STAGE_INSERT_ATOMS,&iap);
470 else if(!strncmp(word[1],"ins_m_atoms",11)) {
471 imp.element1=atoi(word[2]);
472 imp.element2=atoi(word[3]);
473 imp.amount1=atoi(word[4]);
474 imp.amount2=atoi(word[5]);
475 imp.brand1=atoi(word[6]);
476 imp.brand2=atoi(word[7]);
477 imp.crmin=atof(word[8]);
478 imp.crmax=atof(word[9]);
480 for(i=0;i<strlen(word[8]);i++) {
483 imp.attr|=ATOM_ATTR_VB;
486 imp.attr|=ATOM_ATTR_HB;
489 imp.attr|=ATOM_ATTR_VA;
492 imp.attr|=ATOM_ATTR_FP;
495 imp.attr|=ATOM_ATTR_1BP;
498 imp.attr|=ATOM_ATTR_2BP;
501 imp.attr|=ATOM_ATTR_3BP;
508 imp.attr1=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_FP;
509 imp.attr2=ATOM_ATTR_HB|ATOM_ATTR_VA|ATOM_ATTR_1BP|ATOM_ATTR_2BP|ATOM_ATTR_3BP|ATOM_ATTR_FP;
510 add_stage(mdrun,STAGE_INSERT_MIXED_ATOMS,&imp);
517 else if(!strncmp(word[1],"continue",8)) {
518 cp.runs=atoi(word[2]);
519 add_stage(mdrun,STAGE_CONTINUE,&cp);
521 else if(!strncmp(word[1],"anneal",6)) {
523 ap.runs=atoi(word[2]);
525 ap.interval=atoi(word[4]);
526 add_stage(mdrun,STAGE_ANNEAL,&ap);
528 else if(!strncmp(word[1],"set_temp",8)) {
529 if(word[2][0]=='c') {
530 stp.type=SET_TEMP_CURRENT;
534 stp.type=SET_TEMP_VALUE;
535 stp.val=atof(word[2]);
537 add_stage(mdrun,STAGE_SET_TEMP,&stp);
539 else if(!strncmp(word[1],"set_timestep",12)) {
540 stsp.tau=atof(word[2]);
541 add_stage(mdrun,STAGE_SET_TIMESTEP,&stsp);
544 printf("%s unknown stage type: %s\n",
550 printf("%s unknown keyword '%s', skipped!\n",
562 int check_pressure(t_moldyn *moldyn,t_mdrun *mdrun) {
566 if(!(mdrun->sattr&SATTR_PRELAX)) {
570 delta=moldyn->p_avg-moldyn->p_ref;
581 int check_temperature(t_moldyn *moldyn,t_mdrun *mdrun) {
585 if(!(mdrun->sattr&SATTR_TRELAX))
588 delta=moldyn->t_avg-moldyn->t_ref;
599 int displace_atom(t_moldyn *moldyn,t_mdrun *mdrun) {
601 t_displace_atom_params *dap;
605 stage=mdrun->stage.current->data;
608 atom=&(moldyn->atom[dap->nr]);
616 int insert_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
618 t_insert_atoms_params *iap;
628 stage=mdrun->stage.current->data;
633 v.x=0.0; v.y=0.0; v.z=0.0;
637 switch(mdrun->lattice) {
678 printf("%s unknown insertion mode: %02x\n",
684 while(cnt<iap->ins_atoms) {
687 if(iap->type!=INS_POS) {
688 r.x=rand_get_double(&(moldyn->random))*x;
689 r.y=rand_get_double(&(moldyn->random))*y;
690 r.z=rand_get_double(&(moldyn->random))*z;
701 if(iap->type!=INS_TOTAL) {
708 dmin=1000; // for sure too high!
709 for(i=0;i<moldyn->count;i++) {
710 atom=&(moldyn->atom[i]);
711 v3_sub(&dist,&(atom->r),&r);
712 check_per_bound(moldyn,&dist);
713 d=v3_absolute_square(&dist);
714 if(d<(iap->cr*iap->cr)) {
723 add_atom(moldyn,iap->element,pse_mass[iap->element],
724 iap->brand,iap->attr,&r,&v);
725 printf("%s atom inserted (%d/%d): %f %f %f\n",
726 ME,(iap->cnt_steps+1)*iap->ins_atoms,
727 iap->ins_steps*iap->ins_atoms,r.x,r.y,r.z);
728 printf(" -> d2 = %f/%f\n",dmin,iap->cr*iap->cr);
735 int insert_mixed_atoms(t_moldyn *moldyn,t_mdrun *mdrun) {
738 t_insert_mixed_atoms_params *imp;
740 double x,x0,y,y0,z,z0;
741 double dmin,d,cmin,cmax;
747 stage=mdrun->stage.current->data;
761 cmin=imp->crmin*imp->crmin;
762 cmax=imp->crmax*imp->crmax;
764 while(imp->amount1|imp->amount2) {
769 r.x=rand_get_double(&(moldyn->random))*x;
770 r.y=rand_get_double(&(moldyn->random))*y;
771 r.z=rand_get_double(&(moldyn->random))*z;
775 dmin=1000.0; // for sure too high!
776 for(i=0;i<moldyn->count;i++) {
777 atom=&(moldyn->atom[i]);
778 v3_sub(&dist,&(atom->r),&r);
779 check_per_bound(moldyn,&dist);
780 d=v3_absolute_square(&dist);
792 add_atom(moldyn,imp->element1,pse_mass[imp->element1],
793 imp->brand1,imp->attr1,&r,&v);
794 printf("%s (mixed) atom inserted (%d): %f %f %f\n",
795 ME,imp->amount1,r.x,r.y,r.z);
796 printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax);
803 r.x=rand_get_double(&(moldyn->random))*x;
804 r.y=rand_get_double(&(moldyn->random))*y;
805 r.z=rand_get_double(&(moldyn->random))*z;
809 dmin=1000.0; // for sure too high!
810 for(i=0;i<moldyn->count;i++) {
811 atom=&(moldyn->atom[i]);
812 v3_sub(&dist,&(atom->r),&r);
813 check_per_bound(moldyn,&dist);
814 d=v3_absolute_square(&dist);
826 add_atom(moldyn,imp->element2,pse_mass[imp->element2],
827 imp->brand2,imp->attr2,&r,&v);
828 printf("%s (mixed) atom inserted (%d): %f %f %f\n",
829 ME,imp->amount2,r.x,r.y,r.z);
830 printf(" -> d2 = %f/%f/%f\n",dmin,cmin,cmax);
838 int chaatr(t_moldyn *moldyn,t_mdrun *mdrun) {
841 t_chaattr_params *cap;
845 stage=mdrun->stage.current->data;
848 for(i=0;i<moldyn->count;i++) {
849 atom=&(moldyn->atom[i]);
850 if(cap->type&CHAATTR_ELEMENT) {
851 if(cap->element!=atom->element)
854 if(cap->type&CHAATTR_REGION) {
855 if(cap->x0<atom->r.x)
857 if(cap->y0<atom->r.y)
859 if(cap->z0<atom->r.z)
861 if(cap->x1>atom->r.x)
863 if(cap->y1>atom->r.y)
865 if(cap->z1>atom->r.z)
868 atom->attr=cap->attr;
874 int chsattr(t_moldyn *moldyn,t_mdrun *mdrun) {
877 t_chsattr_params *csp;
879 stage=mdrun->stage.current->data;
882 if(csp->type&CHSATTR_PCTRL) {
884 set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
886 set_p_scale(moldyn,P_SCALE_BERENDSEN,csp->ptau);
888 if(csp->type&CHSATTR_TCTRL) {
890 set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
892 set_t_scale(moldyn,T_SCALE_BERENDSEN,csp->ttau);
894 if(csp->type&CHSATTR_PRELAX) {
896 mdrun->sattr&=(~(SATTR_PRELAX));
898 mdrun->sattr|=SATTR_PRELAX;
901 if(csp->type&CHSATTR_TRELAX) {
903 mdrun->sattr&=(~(SATTR_TRELAX));
905 mdrun->sattr|=SATTR_TRELAX;
908 if(csp->type&CHSATTR_AVGRST) {
910 mdrun->sattr|=SATTR_AVGRST;
912 mdrun->sattr&=(~(SATTR_AVGRST));
914 if(csp->type&CHSATTR_RSTEPS) {
915 mdrun->relax_steps=csp->rsteps;
921 #define stage_print(m) if(!(stage->executed)) \
924 int mdrun_hook(void *ptr1,void *ptr2) {
933 t_insert_atoms_params *iap;
934 t_insert_mixed_atoms_params *imp;
935 t_continue_params *cp;
937 t_set_temp_params *stp;
938 t_set_timestep_params *stsp;
947 /* return immediately if there are no more stage */
948 if(sl->current==NULL)
951 /* get stage description */
952 stage=sl->current->data;
954 /* steps in next schedule */
955 steps=mdrun->relax_steps;
957 /* check whether relaxation steps are necessary */
958 if((check_pressure(moldyn,mdrun)==TRUE)&\
959 (check_temperature(moldyn,mdrun)==TRUE)) {
962 stage_print("\n###########################\n");
963 stage_print("# [mdrun] executing stage #\n");
964 stage_print("###########################\n\n");
966 /* stage specific stuff */
967 switch(stage->type) {
968 case STAGE_DISPLACE_ATOM:
969 stage_print(" -> displace atom\n\n");
970 displace_atom(moldyn,mdrun);
973 case STAGE_INSERT_ATOMS:
974 stage_print(" -> insert atoms\n\n");
976 if(iap->cnt_steps==iap->ins_steps) {
980 insert_atoms(moldyn,mdrun);
986 case STAGE_INSERT_MIXED_ATOMS:
987 stage_print(" -> insert mixed atoms\n\n");
989 insert_mixed_atoms(moldyn,mdrun);
996 stage_print(" -> continue\n\n");
997 if(stage->executed==TRUE) {
1005 stage_print(" -> anneal\n\n");
1007 if(ap->count==ap->runs) {
1011 if(moldyn->t_ref+ap->dt>=0.0)
1012 set_temperature(moldyn,
1013 moldyn->t_ref+ap->dt);
1018 stage_print(" -> change atom attributes\n\n");
1019 chaatr(moldyn,mdrun);
1023 stage_print(" -> change sys attributes\n\n");
1024 chsattr(moldyn,mdrun);
1027 case STAGE_SET_TEMP:
1028 stage_print(" -> set temperature\n\n");
1030 if(stp->type&SET_TEMP_CURRENT) {
1031 set_temperature(moldyn,moldyn->t_avg);
1034 set_temperature(moldyn,stp->val);
1038 case STAGE_SET_TIMESTEP:
1039 stage_print(" -> set timestep\n\n");
1041 mdrun->timestep=stsp->tau;
1045 printf("%s unknwon stage type\n",ME);
1049 /* mark as executed */
1050 stage->executed=TRUE;
1053 if(change_stage==TRUE) {
1054 printf("%s finished stage\n",ME);
1055 if(list_next_f(sl)==L_NO_NEXT_ELEMENT) {
1056 printf("%s no more stages\n",ME);
1066 if(mdrun->sattr&SATTR_AVGRST)
1067 average_reset(moldyn);
1071 /* continue simulation */
1072 moldyn_add_schedule(moldyn,steps,mdrun->timestep);
1077 int main(int argc,char **argv) {
1084 memset(&mdrun,0,sizeof(t_mdrun));
1085 memset(&moldyn,0,sizeof(t_moldyn));
1087 /* parse arguments */
1088 if(mdrun_parse_argv(&mdrun,argc,argv)<0)
1091 /* initialize list system */
1092 list_init_f(&(mdrun.stage));
1094 /* parse config file */
1095 mdrun_parse_config(&mdrun);
1097 /* reset the stage list */
1098 list_reset_f(&(mdrun.stage));
1102 /* prepare simulation */
1104 if(mdrun.continue_file[0]) {
1105 // read the save file
1106 moldyn_read_save_file(&moldyn,mdrun.continue_file);
1107 // manualaadjusting some stuff
1110 rand_init(&(moldyn.random),NULL,1);
1111 moldyn.random.status|=RAND_STAT_VERBOSE;
1114 moldyn_init(&moldyn,argc,argv);
1117 if(set_int_alg(&moldyn,mdrun.intalgo)<0)
1121 set_cutoff(&moldyn,mdrun.cutoff);
1122 if(set_potential(&moldyn,mdrun.potential)<0)
1124 switch(mdrun.potential) {
1125 case MOLDYN_POTENTIAL_AM:
1126 albe_mult_set_params(&moldyn,
1130 case MOLDYN_POTENTIAL_TM:
1131 tersoff_mult_set_params(&moldyn,
1135 case MOLDYN_POTENTIAL_HO:
1136 harmonic_oscillator_set_params(&moldyn,mdrun.element1);
1138 case MOLDYN_POTENTIAL_LJ:
1139 lennard_jones_set_params(&moldyn,mdrun.element1);
1142 printf("%s unknown potential: %02x\n",
1143 ME,mdrun.potential);
1147 /* if it is a continue run, reset schedule and skip lattice init */
1148 if(mdrun.continue_file[0]) {
1149 memset(&(moldyn.schedule),0,sizeof(t_moldyn_schedule));
1153 /* initial lattice and dimensions */
1154 set_dim(&moldyn,mdrun.dim.x,mdrun.dim.y,mdrun.dim.z,mdrun.vis);
1155 set_pbc(&moldyn,mdrun.pbcx,mdrun.pbcy,mdrun.pbcz);
1156 switch(mdrun.lattice) {
1158 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
1159 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1160 mdrun.ly,mdrun.lz,NULL);
1163 create_lattice(&moldyn,DIAMOND,mdrun.lc,mdrun.element1,
1164 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1165 mdrun.ly,mdrun.lz,NULL);
1168 o.x=0.5*0.25*mdrun.lc; o.y=o.x; o.z=o.x;
1169 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element1,
1170 mdrun.m1,DEFAULT_ATOM_ATTR,0,mdrun.lx,
1171 mdrun.ly,mdrun.lz,&o);
1172 o.x+=0.25*mdrun.lc; o.y=o.x; o.z=o.x;
1173 create_lattice(&moldyn,FCC,mdrun.lc,mdrun.element2,
1174 mdrun.m2,DEFAULT_ATOM_ATTR,1,mdrun.lx,
1175 mdrun.ly,mdrun.lz,&o);
1178 set_nn_dist(&moldyn,mdrun.nnd);
1181 printf("%s unknown lattice type: %02x\n",
1185 moldyn_bc_check(&moldyn);
1187 /* temperature and pressure */
1188 set_temperature(&moldyn,mdrun.temperature);
1189 set_pressure(&moldyn,mdrun.pressure);
1190 thermal_init(&moldyn,TRUE);
1193 /* first schedule */
1194 moldyn_add_schedule(&moldyn,mdrun.prerun,mdrun.timestep);
1197 moldyn_set_log_dir(&moldyn,mdrun.sdir);
1198 moldyn_set_report(&moldyn,"CHANGE ME","CHANGE ME TOO");
1200 moldyn_set_log(&moldyn,LOG_TOTAL_ENERGY,mdrun.elog);
1202 moldyn_set_log(&moldyn,LOG_TEMPERATURE,mdrun.tlog);
1204 moldyn_set_log(&moldyn,LOG_PRESSURE,mdrun.plog);
1206 moldyn_set_log(&moldyn,LOG_VOLUME,mdrun.vlog);
1208 moldyn_set_log(&moldyn,VISUAL_STEP,mdrun.visualize);
1210 moldyn_set_log(&moldyn,SAVE_STEP,mdrun.save);
1211 moldyn_set_log(&moldyn,CREATE_REPORT,0);
1212 set_avg_skip(&moldyn,mdrun.avgskip);
1214 /* prepare the hook function */
1215 moldyn_set_schedule_hook(&moldyn,&mdrun_hook,&mdrun);
1217 /* run the simulation */
1218 moldyn_integrate(&moldyn);
1221 moldyn_shutdown(&moldyn);
1223 list_destroy_f(&(mdrun.stage));