@@ -2869,6 +2869,7 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
28692869
28702870 QString particle_type = " A" ; // A is for Atom
28712871
2872+ // This is a dummy atom.
28722873 if (elem.nProtons () == 0 and lj.isDummy ())
28732874 {
28742875 if (is_perturbable)
@@ -2877,6 +2878,9 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
28772878 // Only label dummies for regular simulations.
28782879 else if (not was_perturbable)
28792880 particle_type = " D" ;
2881+
2882+ // Flag that we need to update the atoms.
2883+ update_atoms0 = true ;
28802884 }
28812885
28822886 // This is a new atom type.
@@ -2893,6 +2897,15 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
28932897
28942898 // Hash the atom type against its parameter string, minus the type.
28952899 param_hash.insert (atomtypes[atomtype].mid (6 ), atomtype);
2900+
2901+ if (update_atoms0)
2902+ {
2903+ // Set the type.
2904+ atom.setAtomType (atomtype);
2905+
2906+ // Update the atoms in the vector.
2907+ atoms[i] = atom;
2908+ }
28962909 }
28972910 // This type has been seen before.
28982911 else
@@ -2977,6 +2990,17 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
29772990 update_atoms0 = true ;
29782991 }
29792992 }
2993+ else
2994+ {
2995+ if (update_atoms0)
2996+ {
2997+ // Set the type.
2998+ atom.setAtomType (atomtype);
2999+
3000+ // Update the atoms in the vector.
3001+ atoms[i] = atom;
3002+ }
3003+ }
29803004 }
29813005 }
29823006
@@ -3019,9 +3043,15 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
30193043
30203044 QString particle_type = " A" ; // A is for Atom
30213045
3046+ // This is a dummy atom.
30223047 if (elem.nProtons () == 0 and lj.isDummy ())
3048+ {
30233049 atomtype += " _du" ;
30243050
3051+ // Flag that we need to update the atoms.
3052+ update_atoms1 = true ;
3053+ }
3054+
30253055 // This is a new atom type.
30263056 if (not atomtypes.contains (atomtype))
30273057 {
@@ -3036,6 +3066,15 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
30363066
30373067 // Hash the atom type against its parameter string, minus the type.
30383068 param_hash.insert (atomtypes[atomtype].mid (6 ), atomtype);
3069+
3070+ if (update_atoms1)
3071+ {
3072+ // Set the type.
3073+ atom.setAtomType (atomtype);
3074+
3075+ // Update the atoms in the vector.
3076+ atoms[i] = atom;
3077+ }
30393078 }
30403079
30413080 // This type has been seen before.
@@ -3121,6 +3160,17 @@ static QStringList writeAtomTypes(QMap<QPair<int, QString>, GroMolType> &moltyps
31213160 update_atoms1 = true ;
31223161 }
31233162 }
3163+ else
3164+ {
3165+ if (update_atoms1)
3166+ {
3167+ // Set the type.
3168+ atom.setAtomType (atomtype);
3169+
3170+ // Update the atoms in the vector.
3171+ atoms[i] = atom;
3172+ }
3173+ }
31243174 }
31253175 }
31263176
@@ -3217,14 +3267,6 @@ static QStringList writeMolType(const QString &name, const GroMolType &moltype,
32173267 elem1 = Element::elementWithMass (mol.property (" mass1" ).asA <AtomMasses>()[cgatomidx]);
32183268 }
32193269
3220- // Update the atom types.
3221-
3222- if (elem0.nProtons () == 0 )
3223- atomtype0 += " _du" ;
3224-
3225- if (elem1.nProtons () == 0 )
3226- atomtype1 += " _du" ;
3227-
32283270 QString resnum = QString::number (atom0.residueNumber ().value ());
32293271
32303272 if (not atom0.chainName ().isNull ())
0 commit comments