HTPolyNet 2.6.1__py3-none-any.whl → 2.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- htpolynet/cure/curecontroller.py +207 -26
- htpolynet/repair/cyanate_cap.py +43 -5
- htpolynet/resources/mdp/npt.mdp +2 -1
- htpolynet/resources/mdp/nvt.mdp +2 -1
- {htpolynet-2.6.1.dist-info → htpolynet-2.7.0.dist-info}/METADATA +1 -1
- {htpolynet-2.6.1.dist-info → htpolynet-2.7.0.dist-info}/RECORD +9 -9
- {htpolynet-2.6.1.dist-info → htpolynet-2.7.0.dist-info}/WHEEL +0 -0
- {htpolynet-2.6.1.dist-info → htpolynet-2.7.0.dist-info}/entry_points.txt +0 -0
- {htpolynet-2.6.1.dist-info → htpolynet-2.7.0.dist-info}/licenses/LICENSE +0 -0
htpolynet/cure/curecontroller.py
CHANGED
|
@@ -21,7 +21,7 @@ from ..core.molecule import MoleculeDict
|
|
|
21
21
|
from ..core.topocoord import TopoCoord, BTRC
|
|
22
22
|
from ..cure.reaction import ReactionList
|
|
23
23
|
from ..cure.reaction import reaction_stage
|
|
24
|
-
from ..external.gromacs import gromacs_distance, mdp_modify
|
|
24
|
+
from ..external.gromacs import gmx_energy_trace, gromacs_distance, mdp_modify
|
|
25
25
|
from ..utils import checkpoint as cp
|
|
26
26
|
from ..utils.stringthings import my_logger
|
|
27
27
|
|
|
@@ -54,6 +54,82 @@ def residue_functionality(adf):
|
|
|
54
54
|
"""
|
|
55
55
|
return adf.groupby('resNum')[['z','nreactions']].sum().sum(axis=1)
|
|
56
56
|
|
|
57
|
+
def minimum_image_displacements(before,after,box):
|
|
58
|
+
"""Per-atom displacement magnitudes across a window, under minimum image.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
before (numpy.ndarray): (N,3) positions before the window, nm
|
|
62
|
+
after (numpy.ndarray): (N,3) positions after the window, nm
|
|
63
|
+
box (numpy.ndarray): (3,3) box matrix; only its diagonal is used
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
numpy.ndarray: (N,) displacement magnitudes, nm; empty if N is 0
|
|
67
|
+
"""
|
|
68
|
+
b=np.asarray(before,dtype=float).reshape(-1,3)
|
|
69
|
+
a=np.asarray(after,dtype=float).reshape(-1,3)
|
|
70
|
+
assert a.shape==b.shape,f'shape mismatch {b.shape} vs {a.shape}'
|
|
71
|
+
d=a-b
|
|
72
|
+
L=np.asarray(box,dtype=float)
|
|
73
|
+
L=L.diagonal() if L.ndim==2 else L.reshape(-1)
|
|
74
|
+
# an unset box would make every displacement nan; leave the raw
|
|
75
|
+
# displacement alone instead, which is right for a non-periodic snapshot
|
|
76
|
+
if d.size and np.all(L>0):
|
|
77
|
+
d=d-L*np.round(d/L)
|
|
78
|
+
return np.sqrt((d**2).sum(axis=1))
|
|
79
|
+
|
|
80
|
+
def varshney_criterion(displacements,search_radius):
|
|
81
|
+
"""Summarizes reactive-species mobility against the bond-search capture radius.
|
|
82
|
+
|
|
83
|
+
Varshney sized the original 40 ps relaxation window on the requirement that
|
|
84
|
+
unreacted reactive species diffuse far enough during it to find new
|
|
85
|
+
partners. That requirement decays over a cure: as those species are bonded
|
|
86
|
+
into the growing network they become topologically constrained rather than
|
|
87
|
+
merely slow, and the fixed window silently stops satisfying the criterion it
|
|
88
|
+
was designed against. Nothing in the build reports this, so a window that
|
|
89
|
+
has stopped working looks exactly like one that still works.
|
|
90
|
+
|
|
91
|
+
'crossing_fraction' is the share of still-reactive atoms that moved at least
|
|
92
|
+
one capture radius during the window; it is the quantity that decays.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
displacements (numpy.ndarray): per-atom displacement magnitudes, nm, from :func:`minimum_image_displacements`
|
|
96
|
+
search_radius (float): bond-search capture radius, nm
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
dict: 'n', 'rmsd', 'mean', 'max' (nm) and 'crossing_fraction'; all but 'n' are None when there are no reactive atoms left
|
|
100
|
+
"""
|
|
101
|
+
r=np.asarray(displacements,dtype=float).reshape(-1)
|
|
102
|
+
if r.size==0:
|
|
103
|
+
return {'n':0,'rmsd':None,'mean':None,'max':None,'crossing_fraction':None}
|
|
104
|
+
return {
|
|
105
|
+
'n':int(r.size),
|
|
106
|
+
'rmsd':float(np.sqrt((r**2).mean())),
|
|
107
|
+
'mean':float(r.mean()),
|
|
108
|
+
'max':float(r.max()),
|
|
109
|
+
'crossing_fraction':float((r>=search_radius).mean())
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
def _relax_stage_density(edr_pfx):
|
|
113
|
+
"""Mean density over one relax stage's NPT segment, or None if unavailable.
|
|
114
|
+
|
|
115
|
+
Instrumentation must never be able to fail a build, so every failure path --
|
|
116
|
+
a missing edr, a gmx energy that will not run, an ensemble whose menu has no
|
|
117
|
+
Density -- returns None, and the stage reports '--' instead.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
edr_pfx (str): edr basename, without the '.edr' extension
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
float: mean density in kg/m^3, or None
|
|
124
|
+
"""
|
|
125
|
+
try:
|
|
126
|
+
df=gmx_energy_trace(edr_pfx,['Density'])
|
|
127
|
+
except Exception as e:
|
|
128
|
+
logger.debug(f'no density available from {edr_pfx}: {e}')
|
|
129
|
+
return None
|
|
130
|
+
if df.empty or 'Density' not in df.columns: return None
|
|
131
|
+
return float(df['Density'].mean())
|
|
132
|
+
|
|
57
133
|
def rank_bond_candidates(bdf,reaction_counts=None):
|
|
58
134
|
"""Orders bond candidates ahead of the greedy one-bond-per-residue downselection.
|
|
59
135
|
|
|
@@ -563,6 +639,63 @@ class CureController:
|
|
|
563
639
|
"""
|
|
564
640
|
return f'{self.state.step.value}-{self.state.step}'
|
|
565
641
|
|
|
642
|
+
def _reactive_positions(self,TC:TopoCoord):
|
|
643
|
+
"""Snapshots the positions of every atom that still has a reactive site.
|
|
644
|
+
|
|
645
|
+
'z' is the count of a reactive atom's unused sites, so ``z > 0`` is the
|
|
646
|
+
set of species still looking for a partner -- the same selector the bond
|
|
647
|
+
search itself uses. Bonds only form during the topology update, so this
|
|
648
|
+
set is constant across one relax ladder and the snapshot can be compared
|
|
649
|
+
atom for atom with a later one.
|
|
650
|
+
|
|
651
|
+
Args:
|
|
652
|
+
TC (TopoCoord): global topology and coordinates
|
|
653
|
+
|
|
654
|
+
Returns:
|
|
655
|
+
tuple: (globalIdx array, (N,3) position array), or None if the atom dataframe carries no 'z' attribute or nothing is still reactive
|
|
656
|
+
"""
|
|
657
|
+
adf=TC.Coordinates.A
|
|
658
|
+
if adf is None or not all(c in adf.columns for c in ('z','globalIdx','posX','posY','posZ')): return None
|
|
659
|
+
sel=adf[adf['z']>0]
|
|
660
|
+
if sel.shape[0]==0: return None
|
|
661
|
+
return sel['globalIdx'].to_numpy(),sel[['posX','posY','posZ']].to_numpy(dtype=float)
|
|
662
|
+
|
|
663
|
+
def _report_reactive_mobility(self,TC:TopoCoord,pre_reactive):
|
|
664
|
+
"""Logs Varshney's criterion across the relax window just completed.
|
|
665
|
+
|
|
666
|
+
See :func:`varshney_criterion` for why this is worth reporting. It is
|
|
667
|
+
pure observation: any failure is logged and swallowed, because a
|
|
668
|
+
diagnostic must not be able to fail a build.
|
|
669
|
+
|
|
670
|
+
Args:
|
|
671
|
+
TC (TopoCoord): global topology and coordinates, as left by the relax ladder
|
|
672
|
+
pre_reactive (tuple): the snapshot returned by :meth:`_reactive_positions` before the ladder ran
|
|
673
|
+
"""
|
|
674
|
+
try:
|
|
675
|
+
idx,before=pre_reactive
|
|
676
|
+
adf=TC.Coordinates.A.set_index('globalIdx')
|
|
677
|
+
after=adf.loc[idx,['posX','posY','posZ']].to_numpy(dtype=float)
|
|
678
|
+
r=minimum_image_displacements(before,after,TC.Coordinates.box)
|
|
679
|
+
stats=varshney_criterion(r,self.dicts['controls']['search_radius'])
|
|
680
|
+
except Exception as e:
|
|
681
|
+
logger.debug(f'could not report reactive mobility: {e}')
|
|
682
|
+
return
|
|
683
|
+
if not stats['n']: return
|
|
684
|
+
rcap=self.dicts['controls']['search_radius']
|
|
685
|
+
logger.info(
|
|
686
|
+
f'Reactive-species mobility over relax: rmsd {stats["rmsd"]:.3f} nm, '
|
|
687
|
+
f'max {stats["max"]:.3f} nm, {stats["crossing_fraction"]*100:.0f}% of '
|
|
688
|
+
f'{stats["n"]} crossed the {rcap:.2f} nm search radius'
|
|
689
|
+
)
|
|
690
|
+
if stats['crossing_fraction']<0.25:
|
|
691
|
+
logger.warning(
|
|
692
|
+
f'reactive-species mobility is low: only {stats["crossing_fraction"]*100:.0f}% of '
|
|
693
|
+
f'still-reactive atoms moved a full search radius during relax. The '
|
|
694
|
+
f'relax window is no longer satisfying the criterion it was sized '
|
|
695
|
+
f'against, so later bonds are being chosen from a nearly frozen '
|
|
696
|
+
f'neighborhood'
|
|
697
|
+
)
|
|
698
|
+
|
|
566
699
|
def _distance_attenuation(self,TC:TopoCoord,mode='drag',gromacs_dict={}):
|
|
567
700
|
"""Manages the progressive attenuation of bond parameters for new bonds.
|
|
568
701
|
|
|
@@ -591,7 +724,7 @@ class CureController:
|
|
|
591
724
|
pmaxL,pminL,pmeanL=pdf['current_lengths'].max(),pdf['current_lengths'].min(),pdf['current_lengths'].mean()
|
|
592
725
|
logger.debug(f'1-4 distances lengths avg/min/max: {pmeanL:.3f}/{pminL:.3f}/{pmaxL:.3f}')
|
|
593
726
|
roptions.append(pmaxL)
|
|
594
|
-
logger.info(' Stage Max-distance (nm) Max-1-4-distance (nm)')
|
|
727
|
+
logger.info(' Stage Max-distance (nm) Max-1-4-distance (nm) Density (kg/m3)')
|
|
595
728
|
rcommon=max(roptions)
|
|
596
729
|
for stg_dict in d['equilibration']:
|
|
597
730
|
ensemble=stg_dict['ensemble']
|
|
@@ -605,6 +738,15 @@ class CureController:
|
|
|
605
738
|
mdp_modify(f'{impfx}.mdp',mdp_mods_dict,add_if_missing=(ensemble!='min'))
|
|
606
739
|
this_nstages=int(maxL/d['increment'])
|
|
607
740
|
this_firststage=self.state.current_stage[mode]
|
|
741
|
+
# Varshney's criterion is measured across the whole relax window, so a
|
|
742
|
+
# build resuming mid-ladder cannot report it -- the window it would
|
|
743
|
+
# measure is only the tail. Skip rather than report a partial number.
|
|
744
|
+
pre_reactive=None
|
|
745
|
+
if mode=='relax':
|
|
746
|
+
if this_firststage==0:
|
|
747
|
+
pre_reactive=self._reactive_positions(TC)
|
|
748
|
+
else:
|
|
749
|
+
logger.debug(f'resuming at stage {this_firststage}; skipping the mobility report')
|
|
608
750
|
logger.debug(f'{self.state.step} {this_nstages} {this_firststage}')
|
|
609
751
|
saveT=TC.Topology.copy_bond_parameters(self.bonds_df)
|
|
610
752
|
for i in range(this_firststage,this_nstages):
|
|
@@ -615,11 +757,17 @@ class CureController:
|
|
|
615
757
|
TC.Topology.attenuate_bond_parameters(self.bonds_df,i,this_nstages,init_colname='initial_distance')
|
|
616
758
|
stagepfx=f'{opfx}-stage-{i+1}'
|
|
617
759
|
TC.write_top(f'{stagepfx}.top')
|
|
760
|
+
stage_density=None
|
|
618
761
|
for stg_dict in d['equilibration']:
|
|
619
762
|
ensemble=stg_dict['ensemble']
|
|
620
763
|
impfx=f'{statename}-{ensemble}' # e.g., drag-min, drag-nvt, drag-npt
|
|
621
764
|
TC.grompp_and_mdrun(out=f'{stagepfx}-{ensemble}',mdp=f'{impfx}',**gromacs_dict)
|
|
622
765
|
# logger.debug(f'{TC.files["gro"]}')
|
|
766
|
+
# the relax stages are the only above-Tg constant-pressure time in
|
|
767
|
+
# a cure, and until now nothing looked at the density they produce.
|
|
768
|
+
# Drag runs under restraints, so its density is not comparable.
|
|
769
|
+
if mode=='relax' and ensemble=='npt':
|
|
770
|
+
stage_density=_relax_stage_density(f'{stagepfx}-npt')
|
|
623
771
|
TC.Topology.restore_bond_parameters(saveT)
|
|
624
772
|
TC.add_length_attribute(nbdf,attr_name='current_lengths')
|
|
625
773
|
maxL,minL,meanL=nbdf['current_lengths'].max(),nbdf['current_lengths'].min(),nbdf['current_lengths'].mean()
|
|
@@ -630,48 +778,81 @@ class CureController:
|
|
|
630
778
|
TC.add_length_attribute(pdf,attr_name='current_lengths')
|
|
631
779
|
pmaxL,pminL,pmeanL=pdf['current_lengths'].max(),pdf['current_lengths'].min(),pdf['current_lengths'].mean()
|
|
632
780
|
logger.debug(f'1-4 distances lengths avg/min/max: {pmeanL:.3f}/{pminL:.3f}/{pmaxL:.3f}')
|
|
633
|
-
|
|
781
|
+
dstr='--' if stage_density is None else f'{stage_density:.1f}'
|
|
782
|
+
logger.info(f'{i+1:>10d} {maxL:>17.3f} {pmaxL:>21.3f} {dstr:>15}')
|
|
634
783
|
self.state._to_yaml()
|
|
635
784
|
if mode=='drag':
|
|
636
785
|
TC.Topology.remove_restraints(self.bonds_df)
|
|
786
|
+
if pre_reactive is not None:
|
|
787
|
+
self._report_reactive_mobility(TC,pre_reactive)
|
|
637
788
|
TC.write_top(f'{opfx}-complete.top')
|
|
638
789
|
self._register_bonds(nbdf,pdf,f'{opfx}-{mode}-bonds.csv',bonds_are=('relaxed' if mode=='relax' else 'dragged'))
|
|
639
790
|
self.state.current_stage[mode]=0
|
|
640
791
|
self.state._to_yaml()
|
|
641
792
|
|
|
642
793
|
def check_iterations_vs_functionality(self,TC:TopoCoord):
|
|
643
|
-
"""Warns if the cure
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
794
|
+
"""Warns if the cure produced few or no complete crosslinkers.
|
|
795
|
+
|
|
796
|
+
A system whose crosslinkers did not complete has no junctions: it is a
|
|
797
|
+
monomer melt that equilibrates, reports a sensible density, and looks
|
|
798
|
+
in every other respect like a cured network. Nothing else surfaces
|
|
799
|
+
this. The conversion the cure reports is a *bond* conversion and is
|
|
800
|
+
perfectly happy with it; only a postcure repair stage would notice, and
|
|
801
|
+
only if one is configured.
|
|
802
|
+
|
|
803
|
+
There are two ways to arrive there and this checks for both.
|
|
804
|
+
|
|
805
|
+
The first is a counting constraint. The bond downselection admits at
|
|
806
|
+
most one bond per residue per iteration, so a residue with ``f``
|
|
807
|
+
reactive sites cannot be fully reacted in fewer than ``f`` iterations —
|
|
808
|
+
whatever the bond conversion says — and a cure that reaches its target
|
|
809
|
+
in two iterations leaves *every* trifunctional crosslinker incomplete.
|
|
810
|
+
|
|
811
|
+
The second is ordinary shortfall, and it is not bounded away by any
|
|
812
|
+
iteration count. The bonds a cure forms are not spread evenly across
|
|
813
|
+
its iterations: the per-iteration count decays steeply, and it is the
|
|
814
|
+
*last* iteration that has to supply a crosslinker's final bond. A cure
|
|
815
|
+
that runs exactly ``f`` iterations and spends its last one on almost
|
|
816
|
+
nothing ends up in the same place as one that ran too few, and the
|
|
817
|
+
counting test above passes it in silence. This is not hypothetical —
|
|
818
|
+
a build has reached exactly one complete crosslinker in 240 that way.
|
|
819
|
+
So the completed count itself is checked, which is exact by the time
|
|
820
|
+
this runs and needs no threshold on a proxy for it.
|
|
821
|
+
|
|
822
|
+
``completion_bias`` is not the remedy for either — it changes which
|
|
823
|
+
residues react, not the one-per-residue-per-iteration rule — which
|
|
824
|
+
matters because it is the first thing a user would reach for on seeing
|
|
825
|
+
a low crosslinker conversion.
|
|
660
826
|
|
|
661
827
|
Args:
|
|
662
828
|
TC (TopoCoord): global system topology and coordinates
|
|
663
829
|
"""
|
|
664
830
|
adf=TC.gro_DataFrame('atoms')
|
|
665
|
-
if adf is None or not all(c in adf.columns for c in ('resNum','z','nreactions')): return
|
|
831
|
+
if adf is None or not all(c in adf.columns for c in ('resNum','resName','z','nreactions')): return
|
|
666
832
|
func=residue_functionality(adf)
|
|
667
833
|
if func.empty: return
|
|
668
834
|
fmax=int(func.max())
|
|
835
|
+
if fmax<2: return
|
|
836
|
+
names=adf.loc[adf['resNum']==func.idxmax(),'resName']
|
|
837
|
+
resname=names.iloc[0] if len(names) else f'residue {func.idxmax()}'
|
|
669
838
|
iterations=self.state.iter
|
|
670
|
-
if
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
839
|
+
if iterations<fmax:
|
|
840
|
+
logger.warning(f'The cure ran {iterations} iteration(s), but {resname} carries {fmax} reactive sites and the bond search admits at most one bond per residue per iteration. No {resname} can have reacted at all {fmax} of its sites, whatever bond conversion was reached, so this system contains no fully-reacted {resname} and therefore no crosslink junctions. completion_bias does not change this. To spend more iterations reaching the same conversion, lower CURE.controls.max_conversion_per_iteration or min_bonds_per_iteration.')
|
|
841
|
+
return
|
|
842
|
+
crosslinkers=func[func==fmax].index
|
|
843
|
+
if not len(crosslinkers): return
|
|
844
|
+
counts=residue_reaction_counts(adf).reindex(crosslinkers).fillna(0)
|
|
845
|
+
complete=int((counts>=fmax).sum())
|
|
846
|
+
fraction=complete/len(crosslinkers)
|
|
847
|
+
logger.info(f'{complete} of {len(crosslinkers)} {resname} are fully reacted ({fraction:.1%})')
|
|
848
|
+
# The crosslinker conversion an ideal randomly-branching network of this
|
|
849
|
+
# functionality would show at its gel point, f_c**f with f_c=1/(f-1).
|
|
850
|
+
# An idealization, used only to decide when to raise the volume: below
|
|
851
|
+
# it a run has too few complete crosslinkers for a percolating network
|
|
852
|
+
# to be assumed, whatever the bond conversion says.
|
|
853
|
+
gel_point=(1.0/(fmax-1))**fmax
|
|
854
|
+
if fraction<gel_point:
|
|
855
|
+
logger.warning(f'The cure ran {iterations} iteration(s) and formed enough bonds to report its bond conversion, but only {complete} of {len(crosslinkers)} {resname} ({fraction:.1%}) ended up reacted at all {fmax} of their sites, and only those are crosslink junctions. That is below the {gel_point:.1%} an ideal randomly-branching network of functionality {fmax} would reach at its gel point, so do not assume this system percolates. The usual cause is a cure whose last iteration formed very few bonds, since that is the iteration that has to supply each crosslinker its final bond; the per-iteration bond count decays steeply, so reaching the target conversion is not enough on its own. completion_bias does not change this. To spread the same conversion over more iterations, lower CURE.controls.max_conversion_per_iteration or min_bonds_per_iteration.')
|
|
675
856
|
|
|
676
857
|
def _completion_bias_counts(self,adf):
|
|
677
858
|
"""Returns per-residue reaction counts when the completion bias is enabled, else None.
|
htpolynet/repair/cyanate_cap.py
CHANGED
|
@@ -401,7 +401,8 @@ def _choose_cap_placement(o_xyz, ref_xyz, neighbors, box, oc_len=0.136,
|
|
|
401
401
|
# ---------------------------------------------------------------------------
|
|
402
402
|
|
|
403
403
|
|
|
404
|
-
def _completion_stats(residue_name, n_crosslinkers, n_incomplete, log=True, placement=None
|
|
404
|
+
def _completion_stats(residue_name, n_crosslinkers, n_incomplete, log=True, placement=None,
|
|
405
|
+
bond_histogram=None):
|
|
405
406
|
"""Summarize crosslinker completion and log it.
|
|
406
407
|
|
|
407
408
|
A crosslinker survives this repair only if every one of its sites is
|
|
@@ -417,9 +418,20 @@ def _completion_stats(residue_name, n_crosslinkers, n_incomplete, log=True, plac
|
|
|
417
418
|
n_incomplete (int): how many of them are being dismantled
|
|
418
419
|
log (bool): emit the summary message; False when there is nothing to summarize
|
|
419
420
|
placement (dict): cap-placement summary from :func:`_report_placements`, merged into the result
|
|
421
|
+
bond_histogram (dict): how many crosslinkers carried 0, 1, ... bonds
|
|
422
|
+
*before* repair dismantled any of them, keyed by bond count. This
|
|
423
|
+
is the distribution ``n_complete`` is the top bin of, and it is the
|
|
424
|
+
only record of it: repair rewrites the topology, and the final
|
|
425
|
+
structure does not say which cap came from which ring. Without it
|
|
426
|
+
the independence assumption behind
|
|
427
|
+
``crosslinker conversion = bond conversion ** f`` can only be
|
|
428
|
+
tested through its ``n_complete`` consequence. Zero-filled
|
|
429
|
+
through the full bond count, so the top bin is always present
|
|
430
|
+
and always equals ``n_complete``; that is checked here.
|
|
420
431
|
|
|
421
432
|
Returns:
|
|
422
|
-
dict: n_crosslinkers, n_complete, n_dismantled, crosslinker_conversion
|
|
433
|
+
dict: n_crosslinkers, n_complete, n_dismantled, crosslinker_conversion,
|
|
434
|
+
and prerepair_bond_counts when a histogram was supplied
|
|
423
435
|
"""
|
|
424
436
|
n_complete = n_crosslinkers - n_incomplete
|
|
425
437
|
chi = n_complete / n_crosslinkers if n_crosslinkers else 0.0
|
|
@@ -436,6 +448,24 @@ def _completion_stats(residue_name, n_crosslinkers, n_incomplete, log=True, plac
|
|
|
436
448
|
'n_dismantled': n_incomplete,
|
|
437
449
|
'crosslinker_conversion': chi,
|
|
438
450
|
}
|
|
451
|
+
if bond_histogram is not None:
|
|
452
|
+
out['prerepair_bond_counts'] = {int(k): int(v) for k, v in sorted(bond_histogram.items())}
|
|
453
|
+
# the histogram and the completion count are computed independently, so
|
|
454
|
+
# they are each other's check: the top bin IS the surviving population
|
|
455
|
+
binned = sum(out['prerepair_bond_counts'].values())
|
|
456
|
+
top = out['prerepair_bond_counts'].get(max(out['prerepair_bond_counts'], default=0), 0)
|
|
457
|
+
if binned != n_crosslinkers or top != n_complete:
|
|
458
|
+
logger.warning(
|
|
459
|
+
f'triazine_to_cyanate_cap: pre-repair histogram disagrees with the '
|
|
460
|
+
f'completion count ({binned} binned vs {n_crosslinkers} residues, '
|
|
461
|
+
f'{top} in the top bin vs {n_complete} complete); one of the two '
|
|
462
|
+
f'is wrong and the reported conversion cannot be trusted'
|
|
463
|
+
)
|
|
464
|
+
if log:
|
|
465
|
+
spread = ', '.join(f'{k}:{v}' for k, v in out['prerepair_bond_counts'].items())
|
|
466
|
+
logger.info(
|
|
467
|
+
f'triazine_to_cyanate_cap: pre-repair bonds per {residue_name} -- {spread}'
|
|
468
|
+
)
|
|
439
469
|
if placement:
|
|
440
470
|
out.update(placement)
|
|
441
471
|
return out
|
|
@@ -472,16 +502,22 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
|
|
|
472
502
|
cl_residues = _find_crosslinker_residues(TC, cl['residue'])
|
|
473
503
|
if not cl_residues:
|
|
474
504
|
logger.info(f'triazine_to_cyanate_cap: no {cl["residue"]} residues found; nothing to do')
|
|
475
|
-
return _completion_stats(cl['residue'], 0, 0, log=False
|
|
505
|
+
return _completion_stats(cl['residue'], 0, 0, log=False,
|
|
506
|
+
bond_histogram={n: 0 for n in range(full_bond_count + 1)})
|
|
476
507
|
|
|
477
508
|
incomplete_plans = [] # list of dicts, one per incomplete triazine
|
|
478
509
|
h_to_delete = set() # global H indices, batched for final deletion
|
|
510
|
+
# how many bonds each crosslinker carries before anything is dismantled;
|
|
511
|
+
# repair destroys this distribution, so it has to be counted here or not
|
|
512
|
+
# at all. Zero-filled so the reported shape does not depend on the box.
|
|
513
|
+
bond_histogram = {n: 0 for n in range(full_bond_count + 1)}
|
|
479
514
|
|
|
480
515
|
for resnum, atoms_by_name in cl_residues.items():
|
|
481
516
|
ring_c = [atoms_by_name[n] for n in ring_c_names]
|
|
482
517
|
ring_n = [atoms_by_name[n] for n in ring_n_names]
|
|
483
518
|
bonded_o = [_bonded_bridge_o(TC, c, bridge_residue, bridge_o_names) for c in ring_c]
|
|
484
519
|
k = sum(1 for o in bonded_o if o is not None)
|
|
520
|
+
bond_histogram[k] = bond_histogram.get(k, 0) + 1
|
|
485
521
|
if k >= full_bond_count:
|
|
486
522
|
continue
|
|
487
523
|
# plan dismantle
|
|
@@ -511,7 +547,8 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
|
|
|
511
547
|
f'triazine_to_cyanate_cap: all {len(cl_residues)} {cl["residue"]} '
|
|
512
548
|
f'residues are fully bonded; nothing to do'
|
|
513
549
|
)
|
|
514
|
-
return _completion_stats(cl['residue'], len(cl_residues), 0
|
|
550
|
+
return _completion_stats(cl['residue'], len(cl_residues), 0,
|
|
551
|
+
bond_histogram=bond_histogram)
|
|
515
552
|
|
|
516
553
|
total_caps = sum(len(p['caps']) for p in incomplete_plans)
|
|
517
554
|
free_caps_planned = sum(1 for p in incomplete_plans for c in p['caps'] if c['bonded_o'] is None)
|
|
@@ -679,7 +716,8 @@ def triazine_to_cyanate_cap(TC, moldict, spec, reactions):
|
|
|
679
716
|
)
|
|
680
717
|
|
|
681
718
|
return _completion_stats(cl['residue'], len(cl_residues), len(incomplete_plans),
|
|
682
|
-
placement=placement_summary
|
|
719
|
+
placement=placement_summary,
|
|
720
|
+
bond_histogram=bond_histogram)
|
|
683
721
|
|
|
684
722
|
|
|
685
723
|
# ---------------------------------------------------------------------------
|
htpolynet/resources/mdp/npt.mdp
CHANGED
htpolynet/resources/mdp/nvt.mdp
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: htpolynet
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.7.0
|
|
4
4
|
Summary: Automated MD System Builder for Amorphous Network Polymers
|
|
5
5
|
Project-URL: Source, https://github.com/cameronabrams/htpolynet
|
|
6
6
|
Project-URL: Documentation, https://htpolynet.readthedocs.io/
|
|
@@ -17,7 +17,7 @@ htpolynet/core/topocoord.py,sha256=jtQcwzvzPVNjU9VxBF9iXw8g3KiY55_jGDlwAZDOSjs,1
|
|
|
17
17
|
htpolynet/core/topology.py,sha256=XcFL96x2E4MsMrUr9upjE211-VcPVwLVoPL9vrV4DOw,56954
|
|
18
18
|
htpolynet/cure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
htpolynet/cure/chain.py,sha256=-d5BFE5xUKjFdNkxLfSnCnZIRSJCtr7xuxYzNHBeSgU,5344
|
|
20
|
-
htpolynet/cure/curecontroller.py,sha256=
|
|
20
|
+
htpolynet/cure/curecontroller.py,sha256=w29UIuXoHlpoyrQJIQawn8APj-d3rL3ISeGkAj2ly5o,54236
|
|
21
21
|
htpolynet/cure/expandreactions.py,sha256=_NNsAuOCdgHMBLyEwl6S7VAZyDT5ei-m4OBBXjDE3YQ,13774
|
|
22
22
|
htpolynet/cure/reaction.py,sha256=S-w60HocYknKnGbq1_uwLpKTL5Fte_o7zxwk3FbyQ1I,10557
|
|
23
23
|
htpolynet/external/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -38,7 +38,7 @@ htpolynet/io/gro.py,sha256=QGsAIlTIJlMRxtv_Juo0wdpbICAzyfQvSzzaMWrlMmA,7141
|
|
|
38
38
|
htpolynet/io/mol2.py,sha256=5aU3HmQ5DS0LBF7tBPCNYKzBScwj8V3xfEUcFIrsevk,7314
|
|
39
39
|
htpolynet/io/pdb.py,sha256=Np44dTbM0IcEAzfz6OGuH0rdQ63BGps3kOmkzH6syls,5293
|
|
40
40
|
htpolynet/repair/__init__.py,sha256=cP3i-P-Wc6s0MgoFDp63kbLomM-ti3mMGEgeQzUVKuY,1740
|
|
41
|
-
htpolynet/repair/cyanate_cap.py,sha256=
|
|
41
|
+
htpolynet/repair/cyanate_cap.py,sha256=DHh-9s74twQ-IXwqrkh_BL8-ULSI_CZae57tsTaQuIE,38991
|
|
42
42
|
htpolynet/repair/topology_surgery.py,sha256=aJ1md2SE4UzVU1YTS-Tiox8QXrr1hZwU6cCuEimlSrU,10030
|
|
43
43
|
htpolynet/resources/README.md,sha256=epKLyqtcxtQOSzTYvaGlwhz970UA4vAU7r-iSBbbpmA,1432
|
|
44
44
|
htpolynet/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -55,8 +55,8 @@ htpolynet/resources/mdp/drag-min.mdp,sha256=CrMRQIzwtG4TlYRY-nB1P7HPgdwrpwSJJW6y
|
|
|
55
55
|
htpolynet/resources/mdp/drag-npt.mdp,sha256=vbU-LuDH-CLmB8s3kRx0SYkKMxR7Qjh8PuXGgpC2EGs,911
|
|
56
56
|
htpolynet/resources/mdp/drag-nvt.mdp,sha256=YtyjVt_uMZUn2JtvbC8ESWLKKru2JyNXbr_GJfWz10w,636
|
|
57
57
|
htpolynet/resources/mdp/min.mdp,sha256=xIViAc9gTE5rMAsYrPGYCNu1fnit_NWdcsBI786XvZc,226
|
|
58
|
-
htpolynet/resources/mdp/npt.mdp,sha256=
|
|
59
|
-
htpolynet/resources/mdp/nvt.mdp,sha256=
|
|
58
|
+
htpolynet/resources/mdp/npt.mdp,sha256=WVr0VZUY4A2o7i66hUDEofdV6855KzSFOwi_iHabE6o,1045
|
|
59
|
+
htpolynet/resources/mdp/nvt.mdp,sha256=wQese3JCF9sikpoxjjersKT-Vw6UZP7LIjo9uwMiyNE,681
|
|
60
60
|
htpolynet/resources/mdp/relax-min.mdp,sha256=KsOkmEi3FLBRtAhEUpUPUhuCe_zArfJqTKInKDnl1us,213
|
|
61
61
|
htpolynet/resources/mdp/relax-npt.mdp,sha256=-OsDj4E5rS6YjrF_zEvoWyjZD-_IyCQBbj-amR9cWYo,919
|
|
62
62
|
htpolynet/resources/mdp/relax-nvt.mdp,sha256=iqxPgPU0fxS4cKwd_mOQ4-b0JG8ySArdlFhJvpmTF44,644
|
|
@@ -96,8 +96,8 @@ htpolynet/utils/logsetup.py,sha256=o0mlVXNzqcfua2SAlJPkGSh4lM_bmI10gWwpb9gqYu8,1
|
|
|
96
96
|
htpolynet/utils/profiling.py,sha256=su7qpGEz6FXVU4KT2HQDWG82bc1sgsfpDQBbAfPpsHc,7331
|
|
97
97
|
htpolynet/utils/stringthings.py,sha256=Mr6o55EM8o4YAaVYpjIJj2IxDToNdbPzb-lpQ3w3jFk,1176
|
|
98
98
|
htpolynet/utils/vmd_viz.py,sha256=Crk3Ln88PKiJ9X7DMMkFEVh2Ru6a1y0RUgj3w6EIgFc,10867
|
|
99
|
-
htpolynet-2.
|
|
100
|
-
htpolynet-2.
|
|
101
|
-
htpolynet-2.
|
|
102
|
-
htpolynet-2.
|
|
103
|
-
htpolynet-2.
|
|
99
|
+
htpolynet-2.7.0.dist-info/METADATA,sha256=nGK5VMQ_GIUbZQoGR6o7CxIgDJOJkFSUBWj6Aw8sYi4,6557
|
|
100
|
+
htpolynet-2.7.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
101
|
+
htpolynet-2.7.0.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
|
|
102
|
+
htpolynet-2.7.0.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
|
|
103
|
+
htpolynet-2.7.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|