NAMD
NamdState.C
Go to the documentation of this file.
1 /*
2 *** Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by
3 *** The Board of Trustees of the University of Illinois.
4 *** All rights reserved.
5 **/
6 
7 /*
8  Holds pointers to large molecule data structure, simulation parameters...
9 */
10 
11 #include "InfoStream.h"
12 #include "common.h"
13 #include "Molecule.h"
14 #include "Parameters.h"
15 #include "SimParameters.h"
16 #include "ConfigList.h"
17 #include "PDB.h"
18 #include "NamdState.h"
19 #include "Controller.h"
20 #include "ScriptTcl.h"
21 #include "charm++.h"
22 #ifndef WIN32
23 #include <unistd.h>
24 #endif
25 #include <sys/stat.h>
26 #include "parm.h"
27 #include "ReadAmberParm.h"
28 
29 //#define DEBUGM
30 #include "Debug.h"
31 
32 #include "CompressPsf.h"
33 #include "PluginIOMgr.h"
34 #include "BackEnd.h"
35 #if !defined(WIN64)
36 #include <pthread.h> // for pthread_setname_np
37 #endif
39 {
40  configList = NULL;
41  simParameters = NULL;
42  parameters = NULL;
43  molecule = NULL;
44  pdb = NULL;
45 }
46 
47 int
49 {
50  int ret=0;
51  if (configList != NULL) {
52  DebugM(1, "Config List exists\n");
53  } else ret++;
54 
55  if (simParameters != NULL) {
56  DebugM(1, "SimParameters exists\n");
57  }
58  else ret++;
59 
60  if (parameters != NULL) {
61  DebugM(1,"Parameters exists\n");
62  }
63  else ret++;
64 
65  if (molecule != NULL) {
66  DebugM(1, "Molecule exists\n");
67  }
68  else ret++;
69 
70  if (pdb != NULL) {
71  DebugM(1,"PDB exists \n");
72  }
73  else ret++;
74 
75  return(ret);
76 }
77 
79 {
80  controller=controllerPtr;
81 }
82 
84 {
85  controller->run();
86 }
87 
88 extern void read_binary_coors(char *fname, PDB *pdbobj);
89 
90 #ifdef MEM_OPT_VERSION
91  //Check features that are not supported in the memory optimized
92  //version. --Chao Mei
93 void NamdState::checkMemOptCompatibility(){
94  if(simParameters->genCompressedPsf) {
95  iout << "In the memory optimized version, the compression of molecule information is not supported! "
96  << "Please use the non-memory optimized version.\n" <<endi;
97  NAMD_die("MEMOPT: unsupported usage");
98  }
99 
100  if(simParameters->langevinOn && simParameters->langevinDamping == 0.0) {
101  iout << iWARN << "langevinDamping MUST NOT BE 0.0 IF LANGEVIN IS"
102  <<" TURNED ON IN MEMORY OPTIMIZED VERSION\n" <<endi;
103  NAMD_die("MEMOPT: unsupported feature");
104  }
105  if(simParameters->tCoupleOn)
106  NAMD_die("MEMOPT: tCouple is not supported in memory optimized version");
107  if(simParameters->pairInteractionOn)
108  NAMD_die("MEMOPT: pairInteractionOn could not be enabled in memory optimized version");
109  if(simParameters->alchFepOn || simParameters->alchOn){
110  iout << iWARN << "ALCH: AUTOMATIC DELETION OF BONDED INTERACTIONS "
111  << "BETWEEN INITIAL AND FINAL GROUPS IS NOT SUPPORTED IN MEMORY "
112  << "OPTIMISED VERSION - MANUAL PROCESSING IS NECESSARY\n" << endi;
113  NAMD_die("MEMOPT: unsupported feature");
114  }
115  if(simParameters->alchThermIntOn)
116  NAMD_die("MEMOPT: alchThermIntOn could not be enabled in memory optimized version");
117  if(simParameters->lesOn)
118  NAMD_die("MEMOPT: lesOn could not be enabled in memory optimized version");
119  if(simParameters->soluteScalingOn)
120  NAMD_die("MEMOPT: soluteScalingOn could not be enabled in memory optimized version");
121  if(simParameters->lonepairs) {
122  NAMD_die("MEMOPT: lonepairs could not be enabled in memory optimized version");
123  }
124 }
125 #endif
126 
128  configList = cfgList;
129  if (!configList->okay()) {
130  NAMD_die("Simulation config file is incomplete or contains errors.");
131  }
132  DebugM(1,"NamdState::configFileInit configList okay\n");
133 
134  char *currentdir = 0;
135  simParameters = new SimParameters(configList,currentdir);
136  fflush(stdout);
137  lattice = simParameters->lattice;
138 
139  //Check features that are not supported in the memory optimized
140  //version. --Chao Mei
141 #ifdef MEM_OPT_VERSION
142  checkMemOptCompatibility();
143 #endif
144 
145  //Check rigidBonds type when generating the compressed psf files.
146  if(simParameters->genCompressedPsf) {
147  if(simParameters->rigidBonds == RIGID_NONE){
148  //default to RIGID_ALL
149  simParameters->rigidBonds = RIGID_ALL;
150  }
151  }
152 
153  //name the masterPe thread for use in profiling tools
154 #if ! defined (__CYGWIN__) && !defined(WIN64)
155  // cygwin and msvc can't find this anymore, and no one run traces on windows
156  pthread_setname_np(
157 #if ! defined(__APPLE__)
158  pthread_self(),
159 #endif
160  "NAMD masterPe");
161 #endif
162  return loadStructure(0,0,0);
163 }
164 
165 int NamdState::loadStructure(const char *molFilename, const char *pdbFilename, int reload) {
166 
167  StringList *molInfoFilename;
168  // If it's AMBER force field, read the AMBER style files;
169  // if it's GROMACS, read the GROMACS files;
170  // Otherwise read the CHARMM style files
171 
172  if (simParameters->amberOn) {
173  if (simParameters->oldParmReader) {
174  iout << iWARN << "You are using the old AMBER parm/parm7 reader, which does not support CMAP in ff19SB and will silently skip it.\n" << endi;
175  if ( reload ) NAMD_die("Molecular structure reloading not supported for Amber input files.\n");
176  StringList *parmFilename = configList->find("parmfile");
177  molInfoFilename = parmFilename;
178  StringList *coorFilename = configList->find("ambercoor");
179  // "amber" is a temporary data structure, which records all
180  // the data from the parm file. After copying them into
181  // molecule, parameter and pdb structures, it will be deleted.
182  Ambertoppar *amber;
183  amber = new Ambertoppar;
184  if (amber->readparm(parmFilename->data))
185  { parameters = new Parameters(amber, simParameters->vdwscale14);
186  molecule = new Molecule(simParameters, parameters, amber);
187  if (coorFilename != NULL)
188  pdb = new PDB(coorFilename->data,amber);
189  delete amber;
190  }
191  else
192  NAMD_die("Failed to read AMBER parm file!");
193  parameters->print_param_summary();
194  } else {
195  if ( reload ) NAMD_die("Molecular structure reloading not supported for Amber input files.\n");
196  StringList *parmFilename = configList->find("parmfile");
197  molInfoFilename = parmFilename;
198  StringList *coorFilename = configList->find("ambercoor");
200  if (amber.HasData) {
201  parameters = new Parameters(&amber, simParameters->vdwscale14);
202  molecule = new Molecule(simParameters, parameters, &amber);
203  if (coorFilename != NULL)
204  pdb = new PDB(coorFilename->data,&amber);
205  } else {
206  NAMD_die("Failed to read AMBER parm file!");
207  }
208  parameters->print_param_summary();
209  }
210  }
211  else if (simParameters->gromacsOn) {
212  if ( reload ) NAMD_die("Molecular structure reloading not supported for Gromacs input files.\n");
213  StringList *topFilename = configList->find("grotopfile");
214  molInfoFilename = topFilename;
215  StringList *coorFilename = configList->find("grocoorfile");
216  // "gromacsFile" is a temporary data structure, which records all
217  // the data from the topology file. After copying it into the
218  // molecule and parameter and pdb, it will be deleted.
219  GromacsTopFile *gromacsFile;
220  gromacsFile = new GromacsTopFile(topFilename->data);
221  parameters = new Parameters(gromacsFile,simParameters->minimizeCGOn);
222  if (coorFilename != NULL)
223  pdb = new PDB(coorFilename->data,gromacsFile);
224 
225  molecule = new Molecule(simParameters, parameters, gromacsFile);
226  // XXX does Molecule(needAll,these,arguments)?
227 
228  delete gromacsFile; // XXX unimplemented
229 
230  // XXX add error handling when the file doesn't exist
231  // XXX make sure the right things happen when the parameters are
232  // not even specified.
233  // NAMD_die("Failed to read AMBER parm file!");
234  parameters->print_param_summary();
235  }
236  else if (simParameters->usePluginIO){
237 #ifdef MEM_OPT_VERSION
238  NAMD_die("Using plugin IO is not supported in memory optimized version!");
239 #else
240  if ( pdbFilename ) {
241  NAMD_bug("NamdState::loadStructure pdbFilename non-null with usePluginIO\n");
242  }
243 
244  PluginIOMgr *pIOMgr = new PluginIOMgr();
245 
246  iout << iWARN << "Plugin-based I/O is still in development and may still have bugs\n" << endi;
247 
248  molfile_plugin_t *pIOHandle = pIOMgr->getPlugin();
249  if (pIOHandle == NULL) {
250  NAMD_die("ERROR: Failed to match requested plugin type");
251  }
252  if ( pIOHandle->open_file_read == NULL )
253  NAMD_die("ERROR: Selected plugin type cannot open files");
254  if ( pIOHandle->read_structure == NULL )
255  NAMD_die("ERROR: Selected plugin type cannot read structures");
256  if ( pIOHandle->read_next_timestep == NULL )
257  NAMD_die("ERROR: Selected plugin type cannot read coordinates");
258 
259  StringList *moleculeFilename = configList->find("structure");
260  molInfoFilename = moleculeFilename;
261  if ( ! molFilename ) molFilename = moleculeFilename->data;
262  if ( ! reload ) {
263  StringList *parameterFilename = configList->find("parameters");
264  //****** BEGIN CHARMM/XPLOR type changes
265  // For AMBER use different constructor based on parm_struct!!! -JCP
266  parameters = new Parameters(simParameters, parameterFilename);
267  parameters->print_param_summary();
268  }
269 
270  int numAtoms = 0;
271  //TODO: not sure about the name field in the handler
272  void *plgFile = pIOHandle->open_file_read(molFilename,
273  pIOHandle->name, &numAtoms);
274  if(plgFile == NULL) {
275  NAMD_die("ERROR: Opening structure file failed!");
276  }
277 
278  double fileReadTime = CmiWallTimer();
279  molecule = new Molecule(simParameters, parameters, pIOHandle, plgFile, numAtoms);
280  iout << iINFO << "TIME FOR LOAD MOLECULE STRUCTURE INFORMATION: " << CmiWallTimer() - fileReadTime << "\n" << endi;
281 
282  /* If we are only generating compressed molecule information, the PDB object is not needed */
283  if(!simParameters->genCompressedPsf) {
284  fileReadTime = CmiWallTimer();
285  //get the occupancy data from the Molecule object and then free it
286  //as it is stored in the Molecule object.
287  pdb = new PDB(pIOHandle, plgFile, molecule->numAtoms, molecule->getOccupancyData(), molecule->getBFactorData());
288  molecule->freeOccupancyData();
289  molecule->freeBFactorData();
290  iout << iINFO << "TIME FOR LOADING ATOMS' COORDINATES INFORMATION: " << CmiWallTimer() - fileReadTime << "\n" << endi;
291  }
292 
293  pIOHandle->close_file_read(plgFile);
294  delete pIOMgr;
295 #endif
296  }
297  else
298  {
299  StringList *moleculeFilename = configList->find("structure");
300  molInfoFilename = moleculeFilename;
301  if ( ! molFilename ) molFilename = moleculeFilename->data;
302  if ( ! reload ) {
303  StringList *parameterFilename = configList->find("parameters");
304  //****** BEGIN CHARMM/XPLOR type changes
305  // For AMBER use different constructor based on parm_struct!!! -JCP
306  parameters = new Parameters(simParameters, parameterFilename);
307  //****** END CHARMM/XPLOR type changes
308 
309  parameters->print_param_summary();
310  }
311 
312  double fileReadTime = CmiWallTimer();
313  molecule = new Molecule(simParameters, parameters, (char*)molFilename, configList);
314  iout << iINFO << "TIME FOR READING PSF FILE: " << CmiWallTimer() - fileReadTime << "\n" << endi;
315 }
316 
317  fflush(stdout);
318 
319 #ifdef MEM_OPT_VERSION
320  //upon knowing the number of atoms, it's good time to estimate the number of
321  //input/output processors if their value is not set
322  if(simParameters->numinputprocs==0){
323  int numatoms = molecule->numAtoms;
324  long estval = (sizeof(InputAtom)+2*sizeof(int)+1)*((long)(numatoms));
325  int numprocs = estval>>26; //considering every input proc consumes about 64M.
326  if(numprocs==0){
327  numprocs=1;
328  }else if(numprocs>CkNumPes()){
329  numprocs=CkNumPes();
330  }
331  simParameters->numinputprocs=numprocs;
332  }
333  if(simParameters->numoutputprocs==0){
334  int numatoms = molecule->numAtoms;
335  long estval = (sizeof(Vector)*2)*((long)(numatoms));
336  int numprocs = estval>>26; //considering every input proc consumes about 64M.
337  if(numprocs==0){
338  numprocs=1;
339  }else if(numprocs>CkNumPes()){
340  numprocs=CkNumPes();
341  }
342  simParameters->numoutputprocs=numprocs;
343  }
344  //check the number of output procs that simultaneously write to a file
345  if(simParameters->numoutputwrts > simParameters->numoutputprocs) {
346  simParameters->numoutputwrts = simParameters->numoutputprocs;
347  }
348 
349  if (simParameters->fixedAtomsOn){
350  double fileReadTime = CmiWallTimer();
351  molecule->load_fixed_atoms(configList->find("fixedAtomListFile"));
352  iout << iINFO << "TIME FOR READING FIXED ATOMS FILE: " << CmiWallTimer() - fileReadTime << "\n" << endi;
353  }
354 
355  if (simParameters->constraintsOn){
356  double fileReadTime = CmiWallTimer();
357  molecule->load_constrained_atoms(configList->find("consAtomListFile"));
358  iout << iINFO << "TIME FOR READING CONSTRAINED ATOMS FILE: " << CmiWallTimer() - fileReadTime << "\n" << endi;
359  }
360 #else
361  if (simParameters->extraBondsOn) {
362  //The extra bonds building will be executed in read_compressed_psf in
363  //the memory optimized version, so avoid calling this function in the
364  //memory optimized run.
365  if(!simParameters->useCompressedPsf)
366  molecule->build_extra_bonds(parameters, configList->find("extraBondsFile"));
367  }
368 
369  if (simParameters->monteCarloPressureOn) {
370  // build molecule and atom index in each molecule
371  molecule->build_molecule();
372  }
373 
374  if(simParameters->genCompressedPsf) {
375  double fileReadTime = CmiWallTimer();
376  compress_molecule_info(molecule, molInfoFilename->data, parameters, simParameters, configList);
377  iout << "Finished compressing molecule information, which takes " << CmiWallTimer()-fileReadTime <<"(s)\n"<<endi;
378  BackEnd::exit();
379  }
380 
381  //If using plugin-based IO, the PDB object is already created!
382  StringList *coordinateFilename = NULL;
383  if(!simParameters->usePluginIO) {
384  //In the memory opt version, the coordinates of atoms
385  //are read during startup in parallel with a bincoordinates input
386  //-Chao Mei
387  double fileReadTime = CmiWallTimer();
388  if ( pdbFilename ) {
389  iout << iINFO << "Reading pdb file " << pdbFilename << "\n" << endi;
390  pdb = new PDB(pdbFilename);
391  } else {
392  coordinateFilename = configList->find("coordinates");
393  if (coordinateFilename != NULL) {
394  iout << iINFO << "Reading pdb file " << coordinateFilename->data << "\n" << endi;
395  pdb = new PDB(coordinateFilename->data);
396  }
397  }
398  if (pdb->num_atoms() != molecule->numAtoms) {
399  NAMD_die("Number of pdb and psf atoms are not the same!");
400  }
401  iout << iINFO << "TIME FOR READING PDB FILE: " << CmiWallTimer() - fileReadTime << "\n" << endi;
402  iout << iINFO << "\n" << endi;
403  }
404 
405  // If constraints are active, build the parameters necessary
406  if (simParameters->constraintsOn)
407  {
408  StringList *consRefFile = configList->find("consref");
409  StringList *consKFile = configList->find("conskfile");
410 
411  if (coordinateFilename != NULL) {
412  if(strcasecmp(coordinateFilename->data, consRefFile->data)==0)
413  consRefFile = NULL;
414  if(strcasecmp(coordinateFilename->data, consKFile->data)==0)
415  consKFile = NULL;
416  }
417 
418  molecule->build_constraint_params(consRefFile, consKFile,
419  configList->find("conskcol"),
420  pdb,
421  NULL);
422  }
423 #endif
424  //CkPrintf ("DEBUG--check if StirOn to build stir params..\n");
425 
426  if (simParameters->stirOn)
427  {
428  //CkPrintf ("DEBUG--now to build stir params..\n");
429 
430  molecule->build_stirred_atoms(configList->find("stirFilename"),
431  configList->find("stirredAtomsCol"),
432  pdb,
433  NULL);
434  }
435 
436 
437 #ifndef MEM_OPT_VERSION
438  if (simParameters->fixedAtomsOn)
439  {
440  molecule->build_fixed_atoms(configList->find("fixedatomsfile"),
441  configList->find("fixedatomscol"),
442  pdb,
443  NULL);
444  }
445 #endif
446 
447  /* BEGIN gf */
448  if (simParameters->mgridforceOn)
449  {
450 
451  molecule->build_gridforce_params(configList->find("gridforcefile"),
452  configList->find("gridforcecol"),
453  configList->find("gridforcechargecol"),
454  configList->find("gridforcepotfile"),
455  pdb,
456  NULL);
457  }
458  /* END gf */
459 
460  // If constant forces are active, read the forces necessary
461  if (simParameters->consForceOn) {
462  char *filename = NULL;
463  if (configList->find("consforcefile"))
464  filename = configList->find("consforcefile")->data;
465  molecule->build_constant_forces(filename);
466  }
467 
468 
469  // If user defined DCD active, read the atoms necessary
470  if (simParameters->dcdSelectionOn) {
471  // initialize
472  for(int i=0;i<16;i++)
473  molecule->dcdSelectionParams[i].frequency=0;
474  molecule->parse_dcd_selection_params(configList);
475  }
476 
477  if (simParameters->excludeFromPressure) {
478  molecule->build_exPressure_atoms(
479  configList->find("excludeFromPressureFile"),
480  configList->find("excludeFromPressureCol"),
481  pdb, NULL);
482  }
483 
484  // If moving drag is active, build the parameters necessary
485  if (simParameters->movDragOn) {
486  molecule->build_movdrag_params(configList->find("movDragFile"),
487  configList->find("movDragCol"),
488  configList->find("movDragVelFile"),
489  pdb,
490  NULL);
491  }
492 
493  // If rotating drag is active, build the parameters necessary
494  if (simParameters->rotDragOn) {
495  molecule->build_rotdrag_params(configList->find("rotDragFile"),
496  configList->find("rotDragCol"),
497  configList->find("rotDragAxisFile"),
498  configList->find("rotDragPivotFile"),
499  configList->find("rotDragVelFile"),
500  configList->find("rotDragVelCol"),
501  pdb,
502  NULL);
503  }
504 
505  // If "constant" torque is active, build the parameters necessary
506  if (simParameters->consTorqueOn) {
507  molecule->build_constorque_params(configList->find("consTorqueFile"),
508  configList->find("consTorqueCol"),
509  configList->find("consTorqueAxisFile"),
510  configList->find("consTorquePivotFile"),
511  configList->find("consTorqueValFile"),
512  configList->find("consTorqueValCol"),
513  pdb,
514  NULL);
515  }
516 
517 #ifndef MEM_OPT_VERSION
518  // If langevin dynamics or temperature coupling are active, build
519  // the parameters necessary
520  if (simParameters->langevinOn)
521  {
522  if (simParameters->langevinDamping == 0.0) {
523  molecule->build_langevin_params(configList->find("langevinfile"),
524  configList->find("langevincol"),
525  pdb,
526  NULL);
527  } else {
528  molecule->build_langevin_params(simParameters->langevinDamping,
529  simParameters->drudeDamping,
530  simParameters->langevinHydrogen);
531  }
532  }
533  else if (simParameters->tCoupleOn)
534  {
535  // Temperature coupling uses the same parameters, but with different
536  // names . . .
537  molecule->build_langevin_params(configList->find("tcouplefile"),
538  configList->find("tcouplecol"),
539  pdb,
540  NULL);
541  }
542 
543  // Modifications for alchemical fep
544  // identify the mutant atoms for fep simulation
545  if (simParameters->alchOn) {
546  molecule->build_fep_flags(configList->find("alchfile"),
547  configList->find("alchcol"), pdb, NULL, "alch" );
548  molecule->delete_alch_bonded();
549  if (simParameters->sdScaling) {
550  if (configList->find("unperturbedBondFile") == NULL) {
551  NAMD_die("Input file for Shobana's bond terms is required with sdScaling on");
552  }
553  molecule->build_alch_unpert_bond_lists(configList->find("unperturbedBondFile")->data);
554  }
555  }
556 //fepe
557 
558  if (simParameters->lesOn) {
559  if (simParameters->alchOn) NAMD_bug("FEP/TI and LES are incompatible!");
560  molecule->build_fep_flags(configList->find("lesfile"),
561  configList->find("lescol"), pdb, NULL, "les");
562  }
563  if (simParameters->soluteScalingOn) {
564  molecule->build_ss_flags(configList->find("soluteScalingFile"),
565  configList->find("soluteScalingCol"), pdb, NULL);
566  }
567  if (simParameters->pairInteractionOn) {
568  molecule->build_fep_flags(configList->find("pairInteractionFile"),
569  configList->find("pairInteractionCol"), pdb, NULL, "pairInteraction");
570  }
571  if (simParameters->pressureProfileAtomTypes > 1) {
572  molecule->build_fep_flags(configList->find("pressureProfileAtomTypesFile"),
573  configList->find("pressureProfileAtomTypesCol"), pdb, NULL,
574  "pressureProfileAtomTypes");
575  }
576 
577  #ifdef OPENATOM_VERSION
578  if (simParameters->openatomOn) {
579  molecules->build_qmmm_flags(configList->find("openatomPdbFile",
580  configList->find("openatomPdbCol"), pdb, NULL, "openatomPdb")
581  }
582  #endif // OPENATOM_VERSION
583 
584  if (simParameters->qmForcesOn){
585 
586 #ifdef MEM_OPT_VERSION
587  NAMD_die("QM forces are not supported in memory-optimized builds.");
588 #endif
589 
590 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
591  NAMD_die("QM forces are not compatible with CUDA at this time");
592 #endif
593 
594  molecule->set_qm_replaceAll(simParameters->qmReplaceAll);
595 
596  if (simParameters->qmParamPDBDefined)
597  molecule->prepare_qm(simParameters->qmParamPDB,
598  parameters, configList);
599  else if (pdbFilename)
600  molecule->prepare_qm(pdbFilename,
601  parameters, configList);
602  else
603  molecule->prepare_qm(configList->find("coordinates")->data,
604  parameters, configList);
605 
606  }
607 
608 
609  if (simParameters->LJcorrection) {
610  molecule->compute_LJcorrection();
611  } else if (simParameters->LJcorrectionAlt) {
613  }
614 #endif
615 
616  // JLai checks to see if Go Forces are turned on
617  if (simParameters->goForcesOn) {
618 #ifdef MEM_OPT_VERSION
619  NAMD_die("Go forces are not supported in memory-optimized builds.");
620 #else
621  StringList *moleculeFilename = configList->find("structure");
622  StringList *parameterFilename = configList->find("parameters");
623  StringList *goFilename = configList->find("goParameters");
624  StringList *goStructureFilename = configList->find("goCoordinates");
625 
626  // Added by JLai -- 1.10.12 -- Code to build the Go parameters (from within the Go molecule instead of the parameters object)
627  molecule->build_go_params(goFilename);
628  // Added by JLai -- 6.3.11 -- flag to switch between the different goMethodologies
629  int goMethod = simParameters->goMethod;
630  if (goMethod == 1) { // should probably replace with switch statement
631  iout << iINFO << "Using Go method matrix\n" << endi;
632  molecule->build_go_sigmas(goStructureFilename, NULL);
633  } else if (goMethod == 2) {
634  iout << iINFO << "Using Go method jump table\n" << endi;
635  molecule->build_go_sigmas2(goStructureFilename, NULL);
636  } else if (goMethod == 3) {
637  iout << iINFO << "Using Go method lowmem\n" << endi;
638  molecule->build_go_arrays(goStructureFilename, NULL);
639  } else {
640  NAMD_die("Failed to read goMethod variable in NamdState.C");
641  }
642 #endif
643  }
644  // End of Go code -- JLai
645 
646 #ifndef MEM_OPT_VERSION
647  iout << iINFO << "****************************\n";
648  iout << iINFO << "STRUCTURE SUMMARY:\n";
649  iout << iINFO << molecule->numAtoms << " ATOMS\n";
650  iout << iINFO << molecule->numBonds << " BONDS\n";
651  iout << iINFO << molecule->numAngles << " ANGLES\n";
652  iout << iINFO << molecule->numDihedrals << " DIHEDRALS\n";
653  iout << iINFO << molecule->numImpropers << " IMPROPERS\n";
654  iout << iINFO << molecule->numCrossterms << " CROSSTERMS\n";
655  iout << iINFO << molecule->numExclusions << " EXCLUSIONS\n";
656 
657  //****** BEGIN CHARMM/XPLOR type changes
658  if ((molecule->numMultipleDihedrals) && (simParameters->paraTypeXplorOn))
659  {
660  iout << iINFO << molecule->numMultipleDihedrals
661  << " DIHEDRALS WITH MULTIPLE PERIODICITY (BASED ON PSF FILE)\n";
662  }
663  if ((molecule->numMultipleDihedrals) && (simParameters->paraTypeCharmmOn))
664  {
665  iout << iINFO << molecule->numMultipleDihedrals
666  << " DIHEDRALS WITH MULTIPLE PERIODICITY IGNORED (BASED ON PSF FILE) \n";
667  iout << iINFO
668  << " CHARMM MULTIPLICITIES BASED ON PARAMETER FILE INFO! \n";
669  }
670  //****** END CHARMM/XPLOR type changes
671 
672  if (molecule->numMultipleImpropers)
673  {
674  iout << iINFO << molecule->numMultipleImpropers
675  << " IMPROPERS WITH MULTIPLE PERIODICITY\n";
676  }
677 
678  if (simParameters->constraintsOn)
679  {
680  iout << iINFO << molecule->numConstraints << " CONSTRAINTS\n";
681  }
682 
683  if (simParameters->consForceOn)
684  iout << iINFO << molecule->numConsForce << " CONSTANT FORCES\n";
685 
686  if (simParameters->stirOn)
687  iout << iINFO << molecule->numStirredAtoms << " STIRRED ATOMS\n";
688 
689  if (simParameters->fixedAtomsOn)
690  {
691  iout << iINFO << molecule->numFixedAtoms << " FIXED ATOMS\n";
692  }
693 
694  if (simParameters->rigidBonds)
695  {
696  iout << iINFO << molecule->numRigidBonds << " RIGID BONDS\n";
697  }
698 
699  if (simParameters->fixedAtomsOn && simParameters->rigidBonds)
700  {
701  iout << iINFO << molecule->numFixedRigidBonds <<
702  " RIGID BONDS BETWEEN FIXED ATOMS\n";
703  }
704 
705  /* BEGIN gf */
706  if (simParameters->mgridforceOn)
707  {
708  int i;
709  iout << iINFO << molecule->numGridforceGrids
710  << " GRIDS ACTIVE\n";
711  }
712  /* END gf */
713 
714 //Modifications for alchemical fep
715  if (simParameters->alchOn) {
716  iout << iINFO << "ALCH: "
717  << molecule->numFepInitial <<
718  " ATOMS TO DISAPPEAR IN FINAL STATE\n";
719  iout << iINFO << "ALCH: "
720  << molecule->numFepFinal <<
721  " ATOMS TO APPEAR IN FINAL STATE\n";
722  if (molecule->suspiciousAlchBonds) {
723  iout << iWARN << "ALCH: SUSPICIOUS BONDS BETWEEN INITIAL AND " <<
724  "FINAL GROUPS WERE FOUND" << "\n" << endi;
725  }
726  if (molecule->alchDroppedAngles) {
727  iout << iINFO << "ALCH: "
728  << molecule->alchDroppedAngles <<
729  " ANGLES LINKING INITIAL AND FINAL ATOMS DELETED\n";
730  }
731  if (molecule->alchDroppedDihedrals) {
732  iout << iINFO << "ALCH: "
733  << molecule->alchDroppedDihedrals <<
734  " DIHEDRALS LINKING INITIAL AND FINAL ATOMS DELETED\n";
735  }
736  if (molecule->alchDroppedImpropers) {
737  iout << iINFO << "ALCH: "
738  << molecule->alchDroppedImpropers <<
739  " IMPROPERS LINKING INITIAL AND FINAL ATOMS DELETED\n";
740  }
741  }
742 //fepe
743 
744  if (simParameters->lesOn) {
745  iout << iINFO << molecule->numFepInitial <<
746  " LOCALLY ENHANCED ATOMS ENABLED\n";
747  }
748 
749  if (simParameters->soluteScalingOn) {
750  iout << iINFO << " SOLUTE SCALING ENABLED\n";
751  }
752 
753  if (simParameters->pairInteractionOn) {
754  iout << iINFO << "PAIR INTERACTION GROUP 1 CONTAINS "
755  << molecule->numFepInitial << " ATOMS\n";
756  if (!simParameters->pairInteractionSelf) {
757  iout << iINFO << "PAIR INTERACTION GROUP 2 CONTAINS "
758  << molecule->numFepFinal << " ATOMS\n";
759  }
760  }
761 
762 #if 1
763  if (molecule->numLonepairs != 0) {
764  iout << iINFO << molecule->numLonepairs << " LONE PAIRS\n";
765  }
766  if (molecule->numDrudeAtoms != 0) {
767  iout << iINFO << molecule->numDrudeAtoms << " DRUDE ATOMS\n";
768  }
769  iout << iINFO << molecule->num_deg_freedom(1)
770  << " DEGREES OF FREEDOM\n";
771  if (simParameters->drudeOn) {
772  int g_bond = 3 * molecule->numDrudeAtoms;
773  int g_com = molecule->num_deg_freedom(1) - g_bond;
774  iout << iINFO << g_com << " DRUDE COM DEGREES OF FREEDOM\n";
775  iout << iINFO << g_bond << " DRUDE BOND DEGREES OF FREEDOM\n";
776  }
777 #endif
778 #if 0
779  {
780  // Copied from Controller::printEnergies()
781  int64 numAtoms = molecule->numAtoms;
782  int64 numDegFreedom = 3 * numAtoms;
783  int numLonepairs = molecule->numLonepairs;
784  int numFixedAtoms = molecule->numFixedAtoms;
785  if ( numFixedAtoms ) numDegFreedom -= 3 * numFixedAtoms;
786  if ( ! ( numFixedAtoms || molecule->numConstraints
787  || simParameters->comMove || simParameters->langevinOn ) ) {
788  numDegFreedom -= 3;
789  }
790  if (numLonepairs) numDegFreedom -= 3 * numLonepairs;
791  int numRigidBonds = molecule->numRigidBonds;
792  int numFixedRigidBonds = molecule->numFixedRigidBonds;
793  // numLonepairs is subtracted here because all lonepairs have a rigid bond
794  // to oxygen, but all of the LP degrees of freedom are dealt with above
795  numDegFreedom -= ( numRigidBonds - numFixedRigidBonds - numLonepairs);
796  iout << iINFO << numDegFreedom << " DEGREES OF FREEDOM\n";
797  }
798 #endif
799 
800  iout << iINFO << molecule->numHydrogenGroups << " HYDROGEN GROUPS\n";
801  iout << iINFO << molecule->maxHydrogenGroupSize
802  << " ATOMS IN LARGEST HYDROGEN GROUP\n";
803  iout << iINFO << molecule->numMigrationGroups << " MIGRATION GROUPS\n";
804  iout << iINFO << molecule->maxMigrationGroupSize
805  << " ATOMS IN LARGEST MIGRATION GROUP\n";
806  if (simParameters->fixedAtomsOn)
807  {
808  iout << iINFO << molecule->numFixedGroups <<
809  " HYDROGEN GROUPS WITH ALL ATOMS FIXED\n";
810  }
811 
812  {
813  BigReal totalMass = 0;
814  BigReal totalCharge = 0;
815  int i;
816  for ( i = 0; i < molecule->numAtoms; ++i ) {
817  totalMass += molecule->atommass(i);
818  totalCharge += molecule->atomcharge(i);
819  }
820  iout << iINFO << "TOTAL MASS = " << totalMass << " amu\n";
821  iout << iINFO << "TOTAL CHARGE = " << totalCharge << " e\n";
822 
823  BigReal volume = lattice.volume();
824  if ( volume ) {
825  iout << iINFO << "MASS DENSITY = "
826  << ((totalMass/volume) / 0.6022) << " g/cm^3\n";
827  iout << iINFO << "ATOM DENSITY = "
828  << (molecule->numAtoms/volume) << " atoms/A^3\n";
829  }
830  }
831 
832  iout << iINFO << "*****************************\n";
833  iout << endi;
834  fflush(stdout);
835 
836  StringList *binCoordinateFilename = configList->find("bincoordinates");
837  if ( binCoordinateFilename && ! reload ) {
838  read_binary_coors(binCoordinateFilename->data, pdb);
839  }
840 
841  DebugM(4, "::configFileInit() - printing Molecule Information\n");
842 
843  molecule->print_atoms(parameters);
844  molecule->print_bonds(parameters);
845  molecule->print_exclusions();
846  fflush(stdout);
847 #endif
848 
849  DebugM(4, "::configFileInit() - done printing Molecule Information\n");
850  DebugM(1, "::configFileInit() - done\n");
851 
852  return(0);
853 }
854 
Real atomcharge(int anum) const
Definition: Molecule.h:1124
int numFixedGroups
Definition: Molecule.h:639
void build_gridforce_params(StringList *, StringList *, StringList *, StringList *, PDB *, char *)
Definition: Molecule.C:6610
int suspiciousAlchBonds
Definition: Molecule.h:592
DCDParams dcdSelectionParams[16]
Definition: Molecule.h:482
std::ostream & iINFO(std::ostream &s)
Definition: InfoStream.C:81
int frequency
Definition: common.h:255
Definition: PDB.h:36
int alchDroppedDihedrals
Definition: Molecule.h:594
int numBonds
Definition: Molecule.h:589
void print_bonds(Parameters *)
Definition: Molecule.C:5597
Bool monteCarloPressureOn
int status()
Definition: NamdState.C:48
void build_extra_bonds(Parameters *parameters, StringList *file)
void print_exclusions()
Definition: Molecule.C:5634
int numHydrogenGroups
Definition: Molecule.h:635
molfile_plugin_t * getPlugin()
Definition: PluginIOMgr.h:22
static void exit(int status=0)
Definition: BackEnd.C:284
Definition: Vector.h:72
Bool excludeFromPressure
static int numatoms
Definition: ScriptTcl.C:65
int alchDroppedImpropers
Definition: Molecule.h:595
#define DebugM(x, y)
Definition: Debug.h:75
std::ostream & endi(std::ostream &s)
Definition: InfoStream.C:54
void build_molecule()
Definition: Molecule.C:3303
int numGridforceGrids
Definition: Molecule.h:626
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:82
void freeOccupancyData()
Definition: Molecule.h:1106
#define iout
Definition: InfoStream.h:51
int num_atoms(void)
Definition: PDB.C:323
int loadStructure(const char *, const char *, int)
Definition: NamdState.C:165
Bool pairInteractionOn
Molecule stores the structural information for the system.
Definition: Molecule.h:174
void build_go_arrays(StringList *, char *)
Definition: GoMolecule.C:951
int numFepFinal
Definition: Molecule.h:644
BigReal vdwscale14
void print_param_summary()
Definition: Parameters.C:6478
void runController(void)
Definition: NamdState.C:83
void build_langevin_params(BigReal coupling, BigReal drudeCoupling, Bool doHydrogen)
NamdState(void)
Definition: NamdState.C:38
int numMultipleImpropers
Definition: Molecule.h:674
int numMultipleDihedrals
Definition: Molecule.h:672
int numLonepairs
Number of lone pairs.
Definition: Molecule.h:610
const float * getBFactorData()
Definition: Molecule.h:1108
void NAMD_bug(const char *err_msg)
Definition: common.C:196
void compute_LJcorrection_alternative()
void read_binary_coors(char *fname, PDB *pdbobj)
Definition: NamdOneTools.C:34
int numFixedRigidBonds
Definition: Molecule.h:641
BigReal langevinDamping
void build_constraint_params(StringList *, StringList *, StringList *, PDB *, char *)
GoChoices goMethod
void build_constorque_params(StringList *, StringList *, StringList *, StringList *, StringList *, StringList *, PDB *, char *)
int numFepInitial
Definition: Molecule.h:643
void set_qm_replaceAll(Bool newReplaceAll)
Definition: Molecule.h:857
int numFixedAtoms
Definition: Molecule.h:632
void prepare_qm(const char *pdbFileName, Parameters *params, ConfigList *cfgList)
Definition: MoleculeQM.C:110
NAMD_HOST_DEVICE BigReal volume(void) const
Definition: Lattice.h:293
int numAngles
Definition: Molecule.h:590
void build_stirred_atoms(StringList *, StringList *, PDB *, char *)
const float * getOccupancyData()
Definition: Molecule.h:1104
int numAtoms
Definition: Molecule.h:586
int numStirredAtoms
Definition: Molecule.h:633
int numCrossterms
Definition: Molecule.h:597
void NAMD_die(const char *err_msg)
Definition: common.C:148
void run(void)
Definition: Controller.C:358
int numConsForce
Definition: Molecule.h:647
Real atommass(int anum) const
Definition: Molecule.h:1114
void build_ss_flags(const StringList *ssfile, const StringList *sscol, PDB *initial_pdb, const char *cwd)
void build_rotdrag_params(StringList *, StringList *, StringList *, StringList *, StringList *, StringList *, PDB *, char *)
int maxMigrationGroupSize
Definition: Molecule.h:638
int numDihedrals
Definition: Molecule.h:591
void build_fep_flags(StringList *, StringList *, PDB *, char *, const char *)
int numImpropers
Definition: Molecule.h:596
int numConstraints
Definition: Molecule.h:624
void build_alch_unpert_bond_lists(char *)
void compress_molecule_info(Molecule *mol, char *psfFileName, Parameters *param, SimParameters *simParam, ConfigList *cfgList)
Definition: CompressPsf.C:436
void build_fixed_atoms(StringList *, StringList *, PDB *, char *)
void compute_LJcorrection()
int pressureProfileAtomTypes
void print_atoms(Parameters *)
Definition: Molecule.C:5551
int maxHydrogenGroupSize
Definition: Molecule.h:636
char * data
Definition: ConfigList.h:48
int numMigrationGroups
Definition: Molecule.h:637
void useController(Controller *controllerPtr)
Definition: NamdState.C:78
void build_go_sigmas(StringList *, char *)
Definition: GoMolecule.C:578
void delete_alch_bonded(void)
#define RIGID_ALL
Definition: SimParameters.h:81
int64_t num_deg_freedom(int isInitialReport=0) const
Definition: Molecule.h:553
void build_exPressure_atoms(StringList *, StringList *, PDB *, char *)
Bool pairInteractionSelf
void build_constant_forces(char *)
Bool qmParamPDBDefined
Ambertoppar readparm(const char *filename)
int numDrudeAtoms
Number of Drude particles.
Definition: Molecule.h:611
Bool okay(void)
Definition: ConfigList.h:120
int alchDroppedAngles
Definition: Molecule.h:593
StringList * find(const char *name) const
Definition: ConfigList.C:341
void build_movdrag_params(StringList *, StringList *, StringList *, PDB *, char *)
char qmParamPDB[NAMD_FILENAME_BUFFER_SIZE]
#define RIGID_NONE
Definition: SimParameters.h:80
BigReal drudeDamping
int readparm(char *)
Definition: parm.C:151
int numRigidBonds
Definition: Molecule.h:640
int64_t int64
Definition: common.h:39
int configListInit(ConfigList *)
Definition: NamdState.C:127
void freeBFactorData()
Definition: Molecule.h:1110
double BigReal
Definition: common.h:123
void parse_dcd_selection_params(ConfigList *configList)
void build_go_params(StringList *)
Definition: GoMolecule.C:80
void build_go_sigmas2(StringList *, char *)
Definition: GoMolecule.C:748
int numExclusions
Definition: Molecule.h:600