STORMM Source Documentation
Loading...
Searching...
No Matches
atomgraph_stage.h
1// -*-c++-*-
2#ifndef STORMM_ATOMGRAPH_STAGE_H
3#define STORMM_ATOMGRAPH_STAGE_H
4
5#include <vector>
6#include <string>
7#include "copyright.h"
8#include "DataTypes/stormm_vector_types.h"
9#include "MoleculeFormat/mdlmol.h"
10#include "atomgraph.h"
11#include "atomgraph_abstracts.h"
12#include "atomgraph_enumerators.h"
13
14namespace stormm {
15namespace topology {
16
17using structure::MdlMol;
18
21constexpr int default_minimum_solute_atoms = 15;
22constexpr char4 wildcard_atom_type = { 'W', 'I', 'L', 'D' };
23constexpr char4 unknown_atom_name = { 'U', 'N', 'K', ' ' };
24constexpr char4 unknown_residue_name = { 'U', 'N', 'K', ' ' };
25constexpr char4 unknown_atom_type = { 'U', 'N', 'K', ' ' };
27
31
36 ScreeningFactorTag(int dihe_idx_in, double elec14_in, double vdw14_in);
37 ScreeningFactorTag(const char4 i_at_in, const char4 l_at_in, double elec14_in, double vdw14_in);
38 ScreeningFactorTag(const char4 i_at_in, const char4 j_at_in, const char4 k_at_in,
39 const char4 l_at_in, double elec14_in, double vdw14_in);
41
51 double elec14;
52 double vdw14;
53};
54
60public:
61
65 AtomGraphStage(int atom_count_in = 0, const std::vector<int> &residue_limits_in = {},
66 ExceptionResponse policy_in = ExceptionResponse::DIE);
67 AtomGraphStage(const AtomGraph *ag_in, ExceptionResponse policy_in = ExceptionResponse::DIE);
68 AtomGraphStage(const AtomGraph &ag_in, ExceptionResponse policy_in = ExceptionResponse::DIE);
69 AtomGraphStage(const MdlMol *cmpd_in, ExceptionResponse policy_in = ExceptionResponse::DIE);
70 AtomGraphStage(const MdlMol &cmpd_in, ExceptionResponse policy_in = ExceptionResponse::DIE);
72
81 AtomGraphStage(const AtomGraphStage &original) = default;
82 AtomGraphStage(AtomGraphStage &&original) = default;
83 AtomGraphStage& operator=(const AtomGraphStage &other) = default;
84 AtomGraphStage& operator=(AtomGraphStage &&other) = default;
86
88 const std::string& getTitle() const;
89
92 const std::string& getOutputFile() const;
93
95 int getAtomCount() const;
96
98 int getResidueCount() const;
99
101 int getMoleculeCount() const;
102
104 double getElectrostatic14Screening() const;
105
107 double getVanDerWaals14Screening() const;
108
123 AtomGraph exportTopology(int minimum_solute_size = default_minimum_solute_atoms,
124 const std::vector<char4> &solute_included_residue_names = {},
125 double hmass_repartition_factor = 1.0) const;
126
130 void setTitle(const std::string &title_in);
131
136 void setOutputFile(const std::string &output_file_in);
137
148 void addUbrdParameters(double k_eq_in, double l_eq_in,
149 const char4 atom_i_type = unknown_atom_type,
150 const char4 atom_k_type = unknown_atom_type);
151
165 void addCImpParameters(double k_eq_in, double phi_in,
166 const char4 atom_i_type = unknown_atom_type,
167 const char4 atom_j_type = unknown_atom_type,
168 const char4 atom_k_type = unknown_atom_type,
169 const char4 atom_l_type = unknown_atom_type);
170
188 void addCmapParameters(const int dimension_in, const std::vector<double> &surf_in,
189 const char4 atom_i_type = unknown_atom_type,
190 const char4 atom_j_type = unknown_atom_type,
191 const char4 atom_k_type = unknown_atom_type,
192 const char4 atom_l_type = unknown_atom_type,
193 const char4 atom_m_type = unknown_atom_type);
194
205 void addBondParameters(double k_eq_in, double l_eq_in,
206 const char4 atom_i_type = unknown_atom_type,
207 const char4 atom_j_type = unknown_atom_type);
208
220 void addAnglParameters(double k_eq_in, double th_eq_in,
221 const char4 atom_i_type = unknown_atom_type,
222 const char4 atom_j_type = unknown_atom_type,
223 const char4 atom_k_type = unknown_atom_type);
224
238 void addDiheParameters(double ampl_in, double period_in, double phi_in,
239 const char4 atom_i_type = unknown_atom_type,
240 const char4 atom_j_type = unknown_atom_type,
241 const char4 atom_k_type = unknown_atom_type,
242 const char4 atom_l_type = unknown_atom_type);
243
271 std::vector<int> addAtoms(const std::vector<int> &z_numbers, int placement = -1,
272 const std::vector<int> &added_residue_limits = {},
273 const std::vector<char4> &added_atom_names = {},
274 const std::vector<char4> &added_atom_types = {},
275 const std::vector<char4> &added_residue_names = {},
276 const std::vector<int> &added_charge_indices = {},
277 const std::vector<int> &added_lennard_jones_indices = {},
278 const std::vector<double> &added_atomic_charges = {});
279
296 int addAtom(int z_number, int placement = -1, const char4 atom_name = { 'U', 'N', 'K', ' ' },
297 const char4 atom_type = { 'U', 'N', 'K', ' ' },
298 const char4 res_name = { 'U', 'N', 'K', ' ' }, int charge_index = -1,
299 int lennard_jones_index = -1, double atomic_charge = 0.0);
300
315 std::vector<int> addVirtualSites(const std::vector<int> &parameter_indices,
316 const std::vector<int> &frame1_atoms,
317 const std::vector<int> &frame2_atoms,
318 const std::vector<int> &frame3_atoms,
319 const std::vector<int> &frame4_atoms);
320
331 int addVirtualSite(int parameter_index, int frame1_atom, int frame2_atom, int frame3_atom = -1,
332 int frame4_atom = -1);
333
340 void setBonds(const std::vector<int> &atom_i, const std::vector<int> &atom_j,
341 const std::vector<int> &parameter_index);
342
349 void setBond(int atom_i, int atom_j, int parameter_index);
350
354 void setElectrostatic14Screening(double screening_factor_in);
355
359 void setVanDerWaals14Screening(double screening_factor_in);
360
361private:
362
363 // The title and source can be specified.
364 ExceptionResponse policy;
365 std::string title;
366 std::string output_file;
370
372 std::vector<Citation> force_fields;
373
374 // Sizing constants follow the AtomGraph class
375 int atom_count;
376 int residue_count;
377 int molecule_count;
378
379 // Arrays of limits define the structures and composition of the molecular system.
380 std::vector<int> residue_limits;
381 std::vector<int> molecule_limits;
384 std::vector<int> molecule_membership;
386 std::vector<int> molecule_contents;
388
389 // Arrays of atomic descriptors define the chemical properties of the system
390 std::vector<int> atomic_numbers;
391
392 // Arrays of atom and residue names
393 std::vector<char4> atom_names;
394 std::vector<char4> atom_types;
397 std::vector<char4> residue_names;
398
399 // Sizing constants on CHARMM force field valence terms
400 int urey_bradley_term_count;
401 int charmm_impr_term_count;
402 int cmap_term_count;
403 int urey_bradley_parameter_count;
404 int charmm_impr_parameter_count;
405 int cmap_surface_count;
406
407 // Atom indexing on CHARMM force field terms
408 std::vector<int> urey_bradley_i_atoms;
409 std::vector<int> urey_bradley_k_atoms;
410 std::vector<int> urey_bradley_parameter_indices;
412 std::vector<int> charmm_impr_i_atoms;
413 std::vector<int> charmm_impr_j_atoms;
414 std::vector<int> charmm_impr_k_atoms;
415 std::vector<int> charmm_impr_l_atoms;
416 std::vector<int> charmm_impr_parameter_indices;
418 std::vector<int> cmap_i_atoms;
419 std::vector<int> cmap_j_atoms;
420 std::vector<int> cmap_k_atoms;
421 std::vector<int> cmap_l_atoms;
422 std::vector<int> cmap_m_atoms;
423 std::vector<int> cmap_surface_indices;
424
425 // Valence parameters for CHARMM force field terms
426 std::vector<int> cmap_surface_dimensions;
429 std::vector<int> cmap_surface_bounds;
432 std::vector<double> urey_bradley_stiffnesses;
434 std::vector<double> urey_bradley_equilibria;
436 std::vector<double> charmm_impr_stiffnesses;
437 std::vector<double> charmm_impr_phase_angles;
438 std::vector<double> cmap_surfaces;
440 std::vector<char4> urey_bradley_i_atom_types;
449 std::vector<char4> urey_bradley_k_atom_types;
451 std::vector<char4> charmm_impr_i_atom_types;
453 std::vector<char4> charmm_impr_j_atom_types;
455 std::vector<char4> charmm_impr_k_atom_types;
457 std::vector<char4> charmm_impr_l_atom_types;
459 std::vector<char4> cmap_i_atom_types;
461 std::vector<char4> cmap_j_atom_types;
463 std::vector<char4> cmap_k_atom_types;
465 std::vector<char4> cmap_l_atom_types;
467 std::vector<char4> cmap_m_atom_types;
469
470 // Sizing constants on common valence terms (AMBER, GROMACS, CHARMM)
471 int bond_term_count;
472 int angl_term_count;
473 int dihe_term_count;
474 int bond_parameter_count;
475 int angl_parameter_count;
476 int dihe_parameter_count;
477 int attenuated_14_type_count;
478 int inferred_14_attenuations;
487
488 // Atom indexing on common valence terms
489 std::vector<int> bond_i_atoms;
490 std::vector<int> bond_j_atoms;
491 std::vector<int> bond_parameter_indices;
492 std::vector<int> angl_i_atoms;
493 std::vector<int> angl_j_atoms;
494 std::vector<int> angl_k_atoms;
495 std::vector<int> angl_parameter_indices;
496 std::vector<int> dihe_i_atoms;
497 std::vector<int> dihe_j_atoms;
498 std::vector<int> dihe_k_atoms;
499 std::vector<int> dihe_l_atoms;
500 std::vector<int> dihe_parameter_indices;
501 std::vector<int> dihe14_parameter_indices;
503 std::vector<int> infr14_i_atoms;
505 std::vector<int> infr14_l_atoms;
507 std::vector<int> infr14_parameter_indices;
513 std::vector<char4> bond_modifiers;
514 std::vector<char4> angl_modifiers;
515 std::vector<char4> dihe_modifiers;
516
517 // Valence parameters for common force field terms
518 std::vector<double> bond_stiffnesses;
519 std::vector<double> bond_equilibria;
520 std::vector<double> angl_stiffnesses;
521 std::vector<double> angl_equilibria;
522 std::vector<double> dihe_amplitudes;
523 std::vector<double> dihe_periodicities;
524 std::vector<double> dihe_phase_angles;
525 std::vector<char4> bond_i_atom_types;
533 std::vector<char4> bond_j_atom_types;
535 std::vector<char4> angl_i_atom_types;
537 std::vector<char4> angl_j_atom_types;
539 std::vector<char4> angl_k_atom_types;
541 std::vector<char4> dihe_i_atom_types;
543 std::vector<char4> dihe_j_atom_types;
545 std::vector<char4> dihe_k_atom_types;
547 std::vector<char4> dihe_l_atom_types;
549
550 // Information relevant to virtual site placement
551 int virtual_site_count;
552 int virtual_site_parameter_set_count;
556 std::vector<int> virtual_site_atoms;
558 std::vector<VirtualSiteKind> vs_frame_types;
560 std::vector<int> virtual_site_frame1_atoms;
562 std::vector<int> virtual_site_frame2_atoms;
563 std::vector<int> virtual_site_frame3_atoms;
565 std::vector<int> virtual_site_frame4_atoms;
567 std::vector<int> virtual_site_parameter_indices;
574 std::vector<double> virtual_site_frame_dim1;
575 std::vector<double> virtual_site_frame_dim2;
577 std::vector<double> virtual_site_frame_dim3;
579
580 // Sizing constants and settings for the non-bonded calculation
581 int charge_type_count;
582 int lj_type_count;
583 int total_exclusions;
584 UnitCellType periodic_box_class;
586 double coulomb_constant;
589 double elec14_screening_factor;
592 double vdw14_screening_factor;
594
595 // Arrays of non-bonded parameters
596 std::vector<int> charge_indices;
597 std::vector<int> lennard_jones_indices;
598 std::vector<int> nb11_exclusion_bounds;
599 std::vector<int> nb11_exclusion_list;
601 std::vector<int> nb12_exclusion_bounds;
602 std::vector<int> nb12_exclusion_list;
603 std::vector<int> nb13_exclusion_bounds;
604 std::vector<int> nb13_exclusion_list;
605 std::vector<int> nb14_exclusion_bounds;
606 std::vector<int> nb14_exclusion_list;
608 std::vector<double> atomic_charges;
609 std::vector<double> charge_parameters;
612 std::vector<double> lj_a_values;
613 std::vector<double> lj_b_values;
614 std::vector<double> lj_c_values;
615 std::vector<double> lj_14_a_values;
616 std::vector<double> lj_14_b_values;
617 std::vector<double> lj_14_c_values;
618 std::vector<double> lj_sigma_values;
621 std::vector<double> lj_epsilon_values;
625 std::vector<double> lj_14_sigma_values;
627 std::vector<double> lj_14_epsilon_values;
629
630 // Whereas the AtomGraph contains condensed arrays of the distinct 1:4 non-bonded screening
631 // parameter pairs, the staging object must collect instructions and create the 1:4 screening
632 // factors for every dihedral in the topology. This is accomplished by accumulating a series of
633 // atom type / screening factor pair records, then building the 1:4 screenings for all dihedrals
634 // in a flash just before exporting a topology. This array covers pairs of electrostatic and
635 // van-der Waals screening factors for up to four distinct atom types.
636 std::vector<ScreeningFactorTag> attn14_tags;
637
638 // Atom, atom type, and residue name overflow keys
639 std::vector<char4> atom_overflow_names;
640 std::vector<char4> atom_overflow_types;
641 std::vector<char4> residue_overflow_names;
642
646 void validateAtomIndex(int atom_index) const;
647
651 void validateFrameIndex(int set_index) const;
652
673 std::vector<int> insertParticles(const std::vector<int> &z_numbers,
674 const std::vector<int> &residue_homes,
675 const std::vector<int> &added_vs_parameter_indices = {},
676 const std::vector<int> &added_vs_frame1_atoms = {},
677 const std::vector<int> &added_vs_frame2_atoms = {},
678 const std::vector<int> &added_vs_frame3_atoms = {},
679 const std::vector<int> &added_vs_frame4_atoms = {});
680
685 std::vector<int> addConnections(const std::vector<int> &atom_i, const std::vector<int> &atom_j);
686
699 int addConnection(int atom_i, int atom_j);
700
708 bool applyProperty(int array_size, int added_count, const std::string &desc);
709
716 std::vector<bool>
717 maskSoluteAtoms(int minimum_solute_size = default_minimum_solute_atoms,
718 const std::vector<char4> &solute_included_residue_names = {}) const;
719
730 std::vector<int> createPrmtopDescriptors(int largest_residue_atoms,
731 int total_exclusions) const;
732
737 std::vector<double> computeAtomicMasses(double hmass_repartition_factor) const;
738
753 void buildNonbonded14Screen(std::vector<double> *attn14_elec_factors,
754 std::vector<double> *attn14_vdw_factors) const;
755};
756
759std::vector<int> atomWithVirtualSiteChildren(const int atom_index,
760 const std::vector<int> &nb11_exclusion_list,
761 const std::vector<int> &nb11_exclusion_bounds);
762
763} // namespace topology
764} // namespace stormm
765
766#endif
A molecular three-dimensional feature. This special class of MOL object properies has its own data li...
Definition mdlmol.h:101
int getAtomCount() const
Get the total number of atoms.
Definition atomgraph_stage.cpp:370
int getMoleculeCount() const
Get the total number of molecules.
Definition atomgraph_stage.cpp:380
void addCmapParameters(const int dimension_in, const std::vector< double > &surf_in, const char4 atom_i_type=unknown_atom_type, const char4 atom_j_type=unknown_atom_type, const char4 atom_k_type=unknown_atom_type, const char4 atom_l_type=unknown_atom_type, const char4 atom_m_type=unknown_atom_type)
Add new parameters for a CHARMM correction map two-dimensional surface term, accessible either by an ...
Definition atomgraph_stage.cpp:722
const std::string & getOutputFile() const
Get the name of the output file to be referenced by the resulting topology. Printed results will go t...
Definition atomgraph_stage.cpp:365
void setVanDerWaals14Screening(double screening_factor_in)
Set the general screening factor on 1:4 van-der Waals interactions.
Definition atomgraph_stage.cpp:1278
double getVanDerWaals14Screening() const
Get the general 1:4 screening factor on van-der Waals interactions.
Definition atomgraph_stage.cpp:390
std::vector< int > addVirtualSites(const std::vector< int > &parameter_indices, const std::vector< int > &frame1_atoms, const std::vector< int > &frame2_atoms, const std::vector< int > &frame3_atoms, const std::vector< int > &frame4_atoms)
Add a series of virtual sites to a topology. A frame parameter set of each specified index must be ad...
Definition atomgraph_stage.cpp:1153
void addBondParameters(double k_eq_in, double l_eq_in, const char4 atom_i_type=unknown_atom_type, const char4 atom_j_type=unknown_atom_type)
Add new bond parameters, accessible either by an index determined by the order of addition or non-bon...
Definition atomgraph_stage.cpp:820
void addAnglParameters(double k_eq_in, double th_eq_in, const char4 atom_i_type=unknown_atom_type, const char4 atom_j_type=unknown_atom_type, const char4 atom_k_type=unknown_atom_type)
Add new angle parameters, accessible either by an index determined by the order of addition or non-bo...
Definition atomgraph_stage.cpp:870
void addUbrdParameters(double k_eq_in, double l_eq_in, const char4 atom_i_type=unknown_atom_type, const char4 atom_k_type=unknown_atom_type)
Add new Urey-Bradley stretching parameters, accessible either by an index determined by the order of ...
Definition atomgraph_stage.cpp:604
AtomGraphStage(const AtomGraphStage &original)=default
The utility of this object lies in its simple construction and independent arrays,...
void setOutputFile(const std::string &output_file_in)
Set the output file.
Definition atomgraph_stage.cpp:599
int addAtom(int z_number, int placement=-1, const char4 atom_name={ 'U', 'N', 'K', ' ' }, const char4 atom_type={ 'U', 'N', 'K', ' ' }, const char4 res_name={ 'U', 'N', 'K', ' ' }, int charge_index=-1, int lennard_jones_index=-1, double atomic_charge=0.0)
Add an atom to the topology. This is a single-atom variant of the addAtoms() function above,...
Definition atomgraph_stage.cpp:1135
void setTitle(const std::string &title_in)
Set the title of the topology.
Definition atomgraph_stage.cpp:580
int getResidueCount() const
Get the total number of residues.
Definition atomgraph_stage.cpp:375
void setBonds(const std::vector< int > &atom_i, const std::vector< int > &atom_j, const std::vector< int > &parameter_index)
Set multiple bonds throughout the structure. The bond term lists, bond parameter lists,...
Definition atomgraph_stage.cpp:1253
AtomGraphStage(int atom_count_in=0, const std::vector< int > &residue_limits_in={}, ExceptionResponse policy_in=ExceptionResponse::DIE)
The constructor can accept a number of atoms, residues, and molecules, an existing AtomGraph,...
Definition atomgraph_stage.cpp:61
AtomGraph exportTopology(int minimum_solute_size=default_minimum_solute_atoms, const std::vector< char4 > &solute_included_residue_names={}, double hmass_repartition_factor=1.0) const
Export the topology based on the internal data arrays. A final list of checks and fixes will be appli...
Definition atomgraph_stage.cpp:396
void setBond(int atom_i, int atom_j, int parameter_index)
Set a bond between two atoms. The bond term lists, bond parameter lists, and number of bonds will be ...
Definition atomgraph_stage.cpp:1267
int addVirtualSite(int parameter_index, int frame1_atom, int frame2_atom, int frame3_atom=-1, int frame4_atom=-1)
Add a virtual site to the topology. This is a single-particle variant of the addVirtualSites() functi...
Definition atomgraph_stage.cpp:1241
void setElectrostatic14Screening(double screening_factor_in)
Set the general screening factor on 1:4 electrostatic interactions.
Definition atomgraph_stage.cpp:1273
double getElectrostatic14Screening() const
Get the general 1:4 screening factor on electrostatic interactions.
Definition atomgraph_stage.cpp:385
void addCImpParameters(double k_eq_in, double phi_in, const char4 atom_i_type=unknown_atom_type, const char4 atom_j_type=unknown_atom_type, const char4 atom_k_type=unknown_atom_type, const char4 atom_l_type=unknown_atom_type)
Add new parameters for a CHARMM improper dihedral, accessible either by an index determined by the or...
Definition atomgraph_stage.cpp:656
std::vector< int > addAtoms(const std::vector< int > &z_numbers, int placement=-1, const std::vector< int > &added_residue_limits={}, const std::vector< char4 > &added_atom_names={}, const std::vector< char4 > &added_atom_types={}, const std::vector< char4 > &added_residue_names={}, const std::vector< int > &added_charge_indices={}, const std::vector< int > &added_lennard_jones_indices={}, const std::vector< double > &added_atomic_charges={})
Add atoms to the system. This will create space for new atoms at the end of each array or at the posi...
Definition atomgraph_stage.cpp:993
void addDiheParameters(double ampl_in, double period_in, double phi_in, const char4 atom_i_type=unknown_atom_type, const char4 atom_j_type=unknown_atom_type, const char4 atom_k_type=unknown_atom_type, const char4 atom_l_type=unknown_atom_type)
Add new dihedral parameters, accessible either by an index determined by the order of addition or non...
Definition atomgraph_stage.cpp:927
const std::string & getTitle() const
Get the title of the topology as it is staged.
Definition atomgraph_stage.cpp:360
A struct to hold information relating to an Amber topology. This struct's member functions are limite...
Definition atomgraph.h:50
Definition stormm_vector_types.h:141
char4 j_at
Atom type of the Jth atom in the proper dihedral.
Definition atomgraph_stage.h:48
double vdw14
Van-der Waals 1:4 screening factor.
Definition atomgraph_stage.h:52
ScreeningFactorTag()
The simplest constructor labels the middle two atom types as "wildcard" and the end types as "unknown...
Definition atomgraph_stage.cpp:33
char4 i_at
Definition atomgraph_stage.h:46
int dihe_idx
Definition atomgraph_stage.h:42
double elec14
Electrostatic 1:4 screening factor.
Definition atomgraph_stage.h:51
char4 l_at
Atom type of atom L in the proper dihedral.
Definition atomgraph_stage.h:50
char4 k_at
Atom type of the Kth atom in the proper dihedral.
Definition atomgraph_stage.h:49