From 7eab1547867fac2fc4c986c923d199b4e119fc12 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Mon, 21 Sep 2020 11:01:04 -0400 Subject: [PATCH 1/7] one-line bug when checking for molecule fragments --- src/molecule.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/molecule.cpp b/src/molecule.cpp index f120a964e3..0b68c5e46e 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -1610,6 +1610,7 @@ void Molecule::body(int flag, int pflag, char *line) int Molecule::findfragment(const char *name) { + if (!fragmentflag) return -1; for (int i = 0; i < nfragments; i++) if (fragmentnames[i] == name) return i; return -1; From 88b8461e0f6885da125f9dd171560cdbbd170609 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 23 Sep 2020 10:19:38 -0400 Subject: [PATCH 2/7] the right molecule fragment fix --- src/molecule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/molecule.cpp b/src/molecule.cpp index 0b68c5e46e..090ce9e77f 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -1610,7 +1610,6 @@ void Molecule::body(int flag, int pflag, char *line) int Molecule::findfragment(const char *name) { - if (!fragmentflag) return -1; for (int i = 0; i < nfragments; i++) if (fragmentnames[i] == name) return i; return -1; @@ -1692,6 +1691,7 @@ void Molecule::initialize() nmolecules = 1; nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0; nibody = ndbody = 0; + nfragments = 0; bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; maxspecial = 0; From e29f838121c5ed730b568a40e819744b8d1e88f6 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 23 Sep 2020 10:28:48 -0400 Subject: [PATCH 3/7] also add error checks --- src/molecule.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/molecule.cpp b/src/molecule.cpp index 090ce9e77f..c9155adc7e 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -634,6 +634,10 @@ void Molecule::read(int flag) error->all(FLERR,"Molecule file has no Body Integers section"); if (bodyflag && ndbody && dbodyflag == 0) error->all(FLERR,"Molecule file has no Body Doubles section"); + if (nmolecules > 0 && !moleculeflag) + error->all(FLERR,"Molecule file has no Molecules section"); + if (nfragments > 0 && !fragmentsflag) + error->all(FLERR,"Molecule file has no Fragments section"); } // auto-generate special bonds if needed and not in file From ed3975054a83d783eea0167dda68b91b849e047d Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 23 Sep 2020 10:30:19 -0400 Subject: [PATCH 4/7] fix typo --- src/molecule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/molecule.cpp b/src/molecule.cpp index c9155adc7e..1248dee306 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -636,7 +636,7 @@ void Molecule::read(int flag) error->all(FLERR,"Molecule file has no Body Doubles section"); if (nmolecules > 0 && !moleculeflag) error->all(FLERR,"Molecule file has no Molecules section"); - if (nfragments > 0 && !fragmentsflag) + if (nfragments > 0 && !fragmentflag) error->all(FLERR,"Molecule file has no Fragments section"); } From 1be766c8cd5677c1327e10c489e30599db9c345d Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 23 Sep 2020 10:37:33 -0400 Subject: [PATCH 5/7] molecule fragment: let's add more checks --- src/molecule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/molecule.cpp b/src/molecule.cpp index 1248dee306..600f865789 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -535,6 +535,8 @@ void Molecule::read(int flag) if (flag) molecules(line); else skip_lines(natoms,line); } else if (strcmp(keyword,"Fragments") == 0) { + if (nfragments == 0) + error->all(FLERR,"Molecule file has fragments but no nfragments setting"); fragmentflag = 1; if (flag) fragments(line); else skip_lines(nfragments,line); From 2b30661b070c178680bfa5afaac43b3cdd078381 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 23 Sep 2020 10:46:23 -0400 Subject: [PATCH 6/7] molecule: correctly update docs --- doc/src/Errors_messages.rst | 9 +++++++++ src/molecule.h | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/doc/src/Errors_messages.rst b/doc/src/Errors_messages.rst index 6bf2e1092c..f2c57a0286 100644 --- a/doc/src/Errors_messages.rst +++ b/doc/src/Errors_messages.rst @@ -5708,6 +5708,9 @@ Doc page with :doc:`WARNING messages ` *Molecule file has dihedrals but no ndihedrals setting* Self-explanatory. +*Molecule file has fragments but no nfragments setting* + Self-explanatory. + *Molecule file has impropers but no nimpropers setting* Self-explanatory. @@ -5717,6 +5720,12 @@ Doc page with :doc:`WARNING messages ` *Molecule file has no Body Integers section* Self-explanatory. +*Molecule file has no Fragments section* + Self-explanatory. + +*Molecule file has no Molecules section* + Self-explanatory. + *Molecule file has special flags but no bonds* Self-explanatory. diff --git a/src/molecule.h b/src/molecule.h index 5a3fa5a327..d7ada5b813 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -241,6 +241,10 @@ E: Molecule file has impropers but no nimpropers setting Self-explanatory. +E: Molecule file has fragments but no nfragments setting + +Self-explanatory. + E: Molecule file shake flags not before shake atoms The order of the two sections is important. @@ -277,6 +281,14 @@ E: Molecule file has no Body Doubles section Self-explanatory. +E: Molecule file has no Molecules section + +Self-explanatory. + +E: Molecule file has no Fragments section + +Self-explanatory. + E: Cannot auto-generate special bonds before simulation box is defined UNDOCUMENTED From b6d98707ece20c08840159b66758aa79a93231ed Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 23 Sep 2020 11:23:10 -0400 Subject: [PATCH 7/7] molecule: revert overzealous error checking --- doc/src/Errors_messages.rst | 3 --- src/molecule.cpp | 2 -- src/molecule.h | 4 ---- 3 files changed, 9 deletions(-) diff --git a/doc/src/Errors_messages.rst b/doc/src/Errors_messages.rst index f2c57a0286..b1b9f38311 100644 --- a/doc/src/Errors_messages.rst +++ b/doc/src/Errors_messages.rst @@ -5723,9 +5723,6 @@ Doc page with :doc:`WARNING messages ` *Molecule file has no Fragments section* Self-explanatory. -*Molecule file has no Molecules section* - Self-explanatory. - *Molecule file has special flags but no bonds* Self-explanatory. diff --git a/src/molecule.cpp b/src/molecule.cpp index 600f865789..123eede230 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -636,8 +636,6 @@ void Molecule::read(int flag) error->all(FLERR,"Molecule file has no Body Integers section"); if (bodyflag && ndbody && dbodyflag == 0) error->all(FLERR,"Molecule file has no Body Doubles section"); - if (nmolecules > 0 && !moleculeflag) - error->all(FLERR,"Molecule file has no Molecules section"); if (nfragments > 0 && !fragmentflag) error->all(FLERR,"Molecule file has no Fragments section"); } diff --git a/src/molecule.h b/src/molecule.h index d7ada5b813..3316cd3f1f 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -281,10 +281,6 @@ E: Molecule file has no Body Doubles section Self-explanatory. -E: Molecule file has no Molecules section - -Self-explanatory. - E: Molecule file has no Fragments section Self-explanatory.