HTPolyNet 1.0.8__py3-none-any.whl → 2.0.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/__init__.py +2 -0
- {HTPolyNet → htpolynet/analysis}/analyze.py +48 -50
- {HTPolyNet → htpolynet/analysis}/plot.py +79 -98
- {HTPolyNet → htpolynet/analysis}/postsim.py +85 -85
- {HTPolyNet → htpolynet/analysis}/utils.py +83 -89
- htpolynet/cli.py +488 -0
- htpolynet/core/__init__.py +0 -0
- htpolynet/core/bondtemplate.py +112 -0
- htpolynet/core/configuration.py +83 -0
- htpolynet/core/coordinates.py +644 -0
- htpolynet/core/molecule.py +998 -0
- htpolynet/core/projectfilesystem.py +616 -0
- {HTPolyNet → htpolynet/core}/runtime.py +280 -217
- {HTPolyNet → htpolynet/core}/topocoord.py +896 -877
- htpolynet/core/topology.py +1138 -0
- htpolynet/cure/__init__.py +0 -0
- htpolynet/cure/chain.py +135 -0
- {HTPolyNet → htpolynet/cure}/curecontroller.py +152 -174
- htpolynet/cure/expandreactions.py +294 -0
- {HTPolyNet → htpolynet/cure}/reaction.py +72 -74
- htpolynet/external/__init__.py +0 -0
- htpolynet/external/ambertools.py +97 -0
- htpolynet/external/command.py +73 -0
- {HTPolyNet → htpolynet/external}/gromacs.py +78 -103
- htpolynet/external/slurm.py +111 -0
- htpolynet/external/software.py +183 -0
- htpolynet/geometry/__init__.py +0 -0
- {HTPolyNet → htpolynet/geometry}/bondlist.py +56 -55
- htpolynet/geometry/lattice.py +32 -0
- htpolynet/geometry/linkcell.py +210 -0
- htpolynet/geometry/matrix4.py +110 -0
- {HTPolyNet → htpolynet/geometry}/ring.py +273 -292
- htpolynet/io/__init__.py +6 -0
- htpolynet/io/gro.py +195 -0
- htpolynet/io/mol2.py +210 -0
- htpolynet/io/pdb.py +157 -0
- htpolynet/resources/__init__.py +0 -0
- htpolynet/resources/example_depot/0-liquid-styrene.sh +134 -0
- htpolynet/resources/example_depot/0-liquid-styrene.tgz +0 -0
- htpolynet/resources/example_depot/1-polystyrene.sh +202 -0
- htpolynet/resources/example_depot/1-polystyrene.tgz +0 -0
- htpolynet/resources/example_depot/2-bisgma-styrene-thermoset.sh +353 -0
- htpolynet/resources/example_depot/2-bisgma-styrene-thermoset.tgz +0 -0
- htpolynet/resources/example_depot/3-pacm-dgeba-epoxy-thermoset.sh +242 -0
- htpolynet/resources/example_depot/3-pacm-dgeba-epoxy-thermoset.tgz +0 -0
- htpolynet/resources/example_depot/4-dfda-fde-epoxy-thermoset.sh +216 -0
- htpolynet/resources/example_depot/4-dfda-fde-epoxy-thermoset.tgz +0 -0
- htpolynet/utils/__init__.py +0 -0
- {HTPolyNet → htpolynet/utils}/banner.py +6 -5
- {HTPolyNet → htpolynet/utils}/checkpoint.py +15 -18
- htpolynet/utils/dataframetools.py +92 -0
- htpolynet/utils/inputcheck.py +49 -0
- htpolynet/utils/logsetup.py +44 -0
- {htpolynet-1.0.8.dist-info → htpolynet-2.0.0.dist-info}/METADATA +22 -31
- htpolynet-2.0.0.dist-info/RECORD +110 -0
- {htpolynet-1.0.8.dist-info → htpolynet-2.0.0.dist-info}/WHEEL +1 -1
- htpolynet-2.0.0.dist-info/entry_points.txt +2 -0
- HTPolyNet/__init__.py +0 -1
- HTPolyNet/ambertools.py +0 -94
- HTPolyNet/bondtemplate.py +0 -111
- HTPolyNet/command.py +0 -42
- HTPolyNet/configuration.py +0 -240
- HTPolyNet/coordinates.py +0 -1100
- HTPolyNet/countTime.py +0 -26
- HTPolyNet/dataframetools.py +0 -134
- HTPolyNet/driver.py +0 -257
- HTPolyNet/expandreactions.py +0 -154
- HTPolyNet/inputcheck.py +0 -51
- HTPolyNet/linkcell.py +0 -322
- HTPolyNet/matrix4.py +0 -110
- HTPolyNet/molecule.py +0 -1247
- HTPolyNet/projectfilesystem.py +0 -483
- HTPolyNet/resources/example_depot/0-liquid-styrene.tgz +0 -0
- HTPolyNet/resources/example_depot/1-polystyrene.tgz +0 -0
- HTPolyNet/resources/example_depot/2-polymethylstyrene.tgz +0 -0
- HTPolyNet/resources/example_depot/3-bisgma-styrene-thermoset.tgz +0 -0
- HTPolyNet/resources/example_depot/4-pacm-dgeba-epoxy-thermoset.tgz +0 -0
- HTPolyNet/resources/example_depot/5-dfda-fde-epoxy-thermoset.tgz +0 -0
- HTPolyNet/software.py +0 -106
- HTPolyNet/topology.py +0 -1228
- HTPolyNet/unused_symmetry_stuff.py +0 -291
- htpolynet-1.0.8.dist-info/RECORD +0 -94
- htpolynet-1.0.8.dist-info/entry_points.txt +0 -2
- {HTPolyNet/resources → htpolynet/analysis}/__init__.py +0 -0
- {HTPolyNet → htpolynet}/resources/README.md +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/DGE-PAC-hi.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/DGE-PAC-lo.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/FDE-DFDA-hi.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/FDE-DFDA-lo.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/GMASTY-hi.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/GMASTY-lo.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/README.md +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/STY.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/pMSTY-hi.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/pMSTY-lo.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/pSTY-hi.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/cfg/pSTY-lo.yaml +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/README.md +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/drag-min.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/drag-npt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/drag-nvt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/min.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/npt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/nvt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/relax-min.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/relax-npt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/relax-nvt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/single-molecule-min.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/mdp/single-molecule-nvt.mdp +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/DFA.pdb +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/DGE.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/EMB.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/FDE.pdb +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/GMA.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/PAC.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/inputs/STY.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/make-monomers.sh +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/DFA.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/DGE.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/EMB.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/FDE.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/GMA.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/PAC.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/pics/STY.png +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/DFA.pdb +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/DGE.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/EMB.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/FDE.pdb +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/GMA.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/PAC.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/molecules/sample-inputs/STY.mol2 +0 -0
- {HTPolyNet → htpolynet}/resources/tcl/readbonds.tcl +0 -0
- {HTPolyNet → htpolynet}/resources/tcl/readgrx.tcl +0 -0
- {HTPolyNet → htpolynet}/resources/tcl/render.tcl +0 -0
- {HTPolyNet → htpolynet/utils}/stringthings.py +0 -0
- {htpolynet-1.0.8.dist-info → htpolynet-2.0.0.dist-info}/licenses/LICENSE +0 -0
htpolynet/__init__.py
ADDED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
.. module:: analyze
|
|
4
|
-
:synopsis: handles the analyze subcommand
|
|
5
|
-
|
|
6
|
-
.. moduleauthor: Cameron F. Abrams, <cfa22@drexel.edu>
|
|
1
|
+
"""Handles the analyze subcommand.
|
|
7
2
|
|
|
3
|
+
Author: Cameron F. Abrams <cfa22@drexel.edu>
|
|
8
4
|
"""
|
|
5
|
+
import json
|
|
9
6
|
import logging
|
|
10
7
|
import os
|
|
11
|
-
|
|
12
|
-
import yaml
|
|
13
|
-
import HTPolyNet.projectfilesystem as pfs
|
|
14
|
-
from HTPolyNet.gromacs import gmx_command
|
|
15
|
-
import HTPolyNet.software as software
|
|
16
|
-
from HTPolyNet.configuration import Configuration
|
|
8
|
+
|
|
17
9
|
from pathlib import Path
|
|
18
10
|
|
|
11
|
+
import yaml
|
|
12
|
+
|
|
13
|
+
from ..core import projectfilesystem as pfs
|
|
14
|
+
from ..core.configuration import Configuration
|
|
15
|
+
from ..external import software as software
|
|
16
|
+
from ..external.gromacs import gmx_command
|
|
17
|
+
from ..utils.logsetup import setup_logging
|
|
18
|
+
|
|
19
19
|
logger=logging.getLogger(__name__)
|
|
20
20
|
|
|
21
21
|
class Analyze:
|
|
@@ -40,9 +40,7 @@ class Analyze:
|
|
|
40
40
|
self.console_output=None
|
|
41
41
|
|
|
42
42
|
def do(self,**gromacs_dict):
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
"""
|
|
43
|
+
"""Handles executing the analysis."""
|
|
46
44
|
p=self.params
|
|
47
45
|
print(p)
|
|
48
46
|
for rk in self.required_keys:
|
|
@@ -105,7 +103,7 @@ class AnalyzeDensity(Analyze):
|
|
|
105
103
|
"""
|
|
106
104
|
default_params={
|
|
107
105
|
'subdir': 'analyze/density',
|
|
108
|
-
'links': ['postsim/equilibrate/equilibrate.tpr','postsim/equilibrate/equilibrate.trr'],
|
|
106
|
+
'links': [f'{pfs.Dirs.postsim}/equilibrate/equilibrate.tpr',f'{pfs.Dirs.postsim}/equilibrate/equilibrate.trr'],
|
|
109
107
|
'gromacs' : {
|
|
110
108
|
'gmx': 'gmx'
|
|
111
109
|
},
|
|
@@ -125,7 +123,7 @@ class AnalyzeDensity(Analyze):
|
|
|
125
123
|
class AnalyzeFFV(Analyze):
|
|
126
124
|
default_params={
|
|
127
125
|
'subdir': 'analyze/freevolume',
|
|
128
|
-
'links': ['postsim/equilibrate/equilibrate.tpr','postsim/equilibrate/equilibrate.trr'],
|
|
126
|
+
'links': [f'{pfs.Dirs.postsim}/equilibrate/equilibrate.tpr',f'{pfs.Dirs.postsim}/equilibrate/equilibrate.trr'],
|
|
129
127
|
'gromacs' : {
|
|
130
128
|
'gmx': 'gmx'
|
|
131
129
|
},
|
|
@@ -165,15 +163,17 @@ class AnalyzeConfiguration:
|
|
|
165
163
|
|
|
166
164
|
@classmethod
|
|
167
165
|
def read(cls,filename,parse=True,**kwargs):
|
|
168
|
-
"""
|
|
166
|
+
"""Generates a new PostsimConfiguration object by reading in the JSON or YAML file indicated by filename.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
filename (str): name of file from which to read new PostsimConfiguration object
|
|
170
|
+
parse (bool): if True, parse the input configuration file, defaults to True
|
|
169
171
|
|
|
170
|
-
:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
:
|
|
174
|
-
|
|
175
|
-
:return: a new PostsimConfiguration object
|
|
176
|
-
:rtype: PostsimConfiguration
|
|
172
|
+
Raises:
|
|
173
|
+
Exception: if extension of filename is not '.json' or '.yaml' or '.yml'
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
PostsimConfiguration: a new PostsimConfiguration object
|
|
177
177
|
"""
|
|
178
178
|
basename,extension=os.path.splitext(filename)
|
|
179
179
|
if extension=='.json':
|
|
@@ -185,14 +185,14 @@ class AnalyzeConfiguration:
|
|
|
185
185
|
|
|
186
186
|
@classmethod
|
|
187
187
|
def _read_json(cls,filename,parse=True,**kwargs):
|
|
188
|
-
"""
|
|
188
|
+
"""Creates a new PostsimConfiguration object by reading from JSON input.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
filename (str): name of JSON file
|
|
192
|
+
parse (bool): if True, parse the JSON data, defaults to True
|
|
189
193
|
|
|
190
|
-
:
|
|
191
|
-
|
|
192
|
-
:param parse: if True, parse the JSON data, defaults to True
|
|
193
|
-
:type parse: bool, optional
|
|
194
|
-
:return: a new PostsimConfiguration object
|
|
195
|
-
:rtype: PostsimConfiguration
|
|
194
|
+
Returns:
|
|
195
|
+
PostsimConfiguration: a new PostsimConfiguration object
|
|
196
196
|
"""
|
|
197
197
|
inst=cls()
|
|
198
198
|
inst.cfgFile=filename
|
|
@@ -204,14 +204,14 @@ class AnalyzeConfiguration:
|
|
|
204
204
|
|
|
205
205
|
@classmethod
|
|
206
206
|
def _read_yaml(cls,filename,parse=True,**kwargs):
|
|
207
|
-
"""
|
|
207
|
+
"""Creates a new PostsimConfiguration object by reading from YAML input.
|
|
208
208
|
|
|
209
|
-
:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
:
|
|
214
|
-
|
|
209
|
+
Args:
|
|
210
|
+
filename (str): name of YAML file
|
|
211
|
+
parse (bool): if True, parse the YAML data, defaults to True
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
PostsimConfiguration: a new PostsimConfiguration object
|
|
215
215
|
"""
|
|
216
216
|
inst=cls()
|
|
217
217
|
inst.cfgFile=filename
|
|
@@ -222,8 +222,7 @@ class AnalyzeConfiguration:
|
|
|
222
222
|
return inst
|
|
223
223
|
|
|
224
224
|
def parse(self,**kwargs):
|
|
225
|
-
"""
|
|
226
|
-
"""
|
|
225
|
+
"""Parses a PostsimConfiguration file to build the list of stages to run."""
|
|
227
226
|
for content in self.baselist:
|
|
228
227
|
analysistype=content['command']
|
|
229
228
|
if analysistype in self.predefined_classes:
|
|
@@ -232,26 +231,25 @@ class AnalyzeConfiguration:
|
|
|
232
231
|
self.stagelist.append(self.default_class(content))
|
|
233
232
|
|
|
234
233
|
def analyze(args):
|
|
235
|
-
"""
|
|
234
|
+
"""Handles the analyze subcommand for managing gromacs-based trajectory analyses.
|
|
236
235
|
|
|
237
|
-
:
|
|
238
|
-
|
|
236
|
+
Args:
|
|
237
|
+
args (argparse.Namespace): command-line arguments
|
|
239
238
|
"""
|
|
240
|
-
|
|
241
|
-
logging.basicConfig(format='%(levelname)s> %(message)s',level=loglevel_numeric)
|
|
239
|
+
setup_logging(args.loglevel, no_banner=args.no_banner)
|
|
242
240
|
ess='y' if len(args.proj)==0 else 'ies'
|
|
243
241
|
ogromacs={}
|
|
244
242
|
if args.ocfg:
|
|
245
|
-
ocfg=Configuration.read(args.ocfg
|
|
246
|
-
ogromacs=ocfg.
|
|
243
|
+
ocfg=Configuration.read(args.ocfg)
|
|
244
|
+
ogromacs=ocfg.gromacs
|
|
247
245
|
cfg=AnalyzeConfiguration.read(args.cfg)
|
|
248
246
|
logger.debug(f'{cfg.baselist}')
|
|
249
247
|
logger.info(f'Project director{ess}: {args.proj}')
|
|
250
248
|
software.sw_setup()
|
|
251
249
|
logger.debug(f'ogromacs {ogromacs}')
|
|
252
250
|
for d in args.proj:
|
|
253
|
-
pfs.pfs_setup(root=os.getcwd(),topdirs=
|
|
254
|
-
pfs.go_to(
|
|
251
|
+
pfs.pfs_setup(root=os.getcwd(),topdirs=pfs.Dirs.analyze_topdirs,verbose=True,projdir=d,reProject=False,userlibrary=args.lib)
|
|
252
|
+
pfs.go_to(pfs.Dirs.analyze)
|
|
255
253
|
for stage in cfg.stagelist:
|
|
256
254
|
stage.do(**ogromacs)
|
|
257
255
|
stage.parse_console_output()
|
|
@@ -1,38 +1,35 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
3
|
-
.. module:: plot
|
|
4
|
-
:synopsis: provides plotting functionality
|
|
5
|
-
|
|
6
|
-
.. moduleauthor: Cameron F. Abrams, <cfa22@drexel.edu>
|
|
1
|
+
"""Provides plotting functionality.
|
|
7
2
|
|
|
3
|
+
Author: Cameron F. Abrams <cfa22@drexel.edu>
|
|
8
4
|
"""
|
|
9
|
-
from HTPolyNet.gromacs import *
|
|
10
|
-
from HTPolyNet.utils import *
|
|
11
|
-
from HTPolyNet.banner import banner
|
|
12
|
-
import matplotlib.pyplot as plt
|
|
13
|
-
import matplotlib.cm as cm
|
|
14
|
-
import pandas as pd
|
|
15
5
|
import logging
|
|
16
|
-
|
|
6
|
+
|
|
17
7
|
from datetime import datetime
|
|
8
|
+
|
|
18
9
|
import yaml
|
|
19
10
|
|
|
11
|
+
import matplotlib.cm as cm
|
|
12
|
+
import matplotlib.pyplot as plt
|
|
13
|
+
import networkx as nx
|
|
14
|
+
import pandas as pd
|
|
15
|
+
|
|
16
|
+
from ..analysis.utils import *
|
|
17
|
+
from ..external.gromacs import *
|
|
18
|
+
from ..utils.logsetup import setup_logging
|
|
19
|
+
|
|
20
20
|
logger=logging.getLogger(__name__)
|
|
21
21
|
|
|
22
22
|
# prevents "RuntimeError: main thread is not in main loop" tk bug
|
|
23
23
|
plt.switch_backend('agg')
|
|
24
24
|
|
|
25
25
|
def scatter(df,xcolumn,columns=[],outfile='plot.png',**kwargs):
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
:type columns: list, optional
|
|
34
|
-
:param outfile: name of output image file, defaults to 'plot.png'
|
|
35
|
-
:type outfile: str, optional
|
|
26
|
+
"""Generic scatter plot generator.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
df (pd.DataFrame): dataframe containing data
|
|
30
|
+
xcolumn (str): name of column holding x-data
|
|
31
|
+
columns (list): list of y-value columns to be plotted vs. x, defaults to []
|
|
32
|
+
outfile (str): name of output image file, defaults to 'plot.png'
|
|
36
33
|
"""
|
|
37
34
|
logging.disable(logging.DEBUG)
|
|
38
35
|
cmapname=kwargs.get('colormap','plasma')
|
|
@@ -50,16 +47,15 @@ def scatter(df,xcolumn,columns=[],outfile='plot.png',**kwargs):
|
|
|
50
47
|
|
|
51
48
|
|
|
52
49
|
def trace(qty,edrs,outfile='plot.png',**kwargs):
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:
|
|
61
|
-
|
|
62
|
-
:rtype: list
|
|
50
|
+
"""Generates a plot of the energy-like quantity named by 'qty' vs time by reading data from the list of edr files named in 'edrs'.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
qty (str): name of energy-like quantity; must conform to menu generated by 'gmx energy'
|
|
54
|
+
edrs (list): list of names of edr files to scan, in order
|
|
55
|
+
outfile (str): name of output image file, defaults to 'plot.png'
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
list: the list of average values
|
|
63
59
|
"""
|
|
64
60
|
# disable debug-level logging and above since matplotlib has a lot of debug statements
|
|
65
61
|
logging.disable(logging.DEBUG)
|
|
@@ -111,16 +107,13 @@ def trace(qty,edrs,outfile='plot.png',**kwargs):
|
|
|
111
107
|
return avg
|
|
112
108
|
|
|
113
109
|
def multi_trace(dfL,xnames,ynames,labels=[],xlabel='time [ps]',ylabel='',outfile='plot.png',**kwargs):
|
|
114
|
-
"""
|
|
115
|
-
|
|
116
|
-
:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
:type ynames: list
|
|
122
|
-
:param outfile: name of output image file, defaults to 'plot.png'
|
|
123
|
-
:type outfile: str, optional
|
|
110
|
+
"""Generates a plot of each y vs x in df.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
dfL (list of pandas.DataFrame): list of dataframes, one per trace
|
|
114
|
+
xnames (list): list of x-column names
|
|
115
|
+
ynames (list): list of y-column names, parallel to xnames
|
|
116
|
+
outfile (str): name of output image file, defaults to 'plot.png'
|
|
124
117
|
"""
|
|
125
118
|
# disable debug-level logging and above since matplotlib has a lot of debug statements
|
|
126
119
|
default_units={'Temperature':'K','Pressure':'bar','Density':'kg/m^3','Potential':'kJ/mol'}
|
|
@@ -149,22 +142,16 @@ def multi_trace(dfL,xnames,ynames,labels=[],xlabel='time [ps]',ylabel='',outfile
|
|
|
149
142
|
|
|
150
143
|
|
|
151
144
|
def global_trace(df,names,outfile='plot.png',transition_times=[],markers=[],interval_labels=[],y2names=[],**kwargs):
|
|
152
|
-
"""
|
|
153
|
-
|
|
154
|
-
:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
:param markers: time values at which transitions are marked somehow, I forget, defaults to []
|
|
163
|
-
:type markers: list, optional
|
|
164
|
-
:param interval_labels: list of labels of intervals defined by markers, defaults to []
|
|
165
|
-
:type interval_labels: list, optional
|
|
166
|
-
:param y2names: names of quantities to be plotted on a secondary y axis, defaults to []
|
|
167
|
-
:type y2names: list, optional
|
|
145
|
+
"""Generates custom-formatted multiplots of energy-like quantities named in 'names' in the input dataframe df.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
df (pd.DataFrame): pandas dataframe containing all data
|
|
149
|
+
names (list): list of quantity names (Density, Temperature, etc)
|
|
150
|
+
outfile (str): name of output image file, defaults to 'plot.png'
|
|
151
|
+
transition_times (list): time values at which vertical lines are drawn, defaults to []
|
|
152
|
+
markers (list): time values at which transitions are marked, defaults to []
|
|
153
|
+
interval_labels (list): list of labels of intervals defined by markers, defaults to []
|
|
154
|
+
y2names (list): names of quantities to be plotted on a secondary y axis, defaults to []
|
|
168
155
|
"""
|
|
169
156
|
# disable debug-level logging and above since matplotlib has a lot of debug statements
|
|
170
157
|
default_units={'Temperature':'K','Pressure':'bar','Density':'kg/m^3','Potential':'kJ/mol'}
|
|
@@ -262,12 +249,11 @@ def global_trace(df,names,outfile='plot.png',transition_times=[],markers=[],inte
|
|
|
262
249
|
logging.disable(logging.NOTSET)
|
|
263
250
|
|
|
264
251
|
def network_graph(G,filename,**kwargs):
|
|
265
|
-
"""
|
|
252
|
+
"""Draws a custom formatted network plot from graph G.
|
|
266
253
|
|
|
267
|
-
:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
:type filename: str
|
|
254
|
+
Args:
|
|
255
|
+
G (nx.Graph or nx.DiGraph): a graph from networkx
|
|
256
|
+
filename (str): name of output image filename
|
|
271
257
|
"""
|
|
272
258
|
logging.disable(logging.DEBUG)
|
|
273
259
|
arrows=kwargs.get('arrows',False)
|
|
@@ -296,29 +282,26 @@ _template_2_token_idx=[2,3,6,7]
|
|
|
296
282
|
_template_2_data_idx={'iter':(int,5),'conv':(float,8),'nbonds':(int,10)}
|
|
297
283
|
|
|
298
284
|
def _token_match(l,template,pat_idx):
|
|
299
|
-
"""
|
|
300
|
-
|
|
301
|
-
:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
:
|
|
307
|
-
|
|
308
|
-
:rtype: bool
|
|
285
|
+
"""Returns True if tokens indexed by pat_idx in the space-split l and template match.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
l (str): probe string
|
|
289
|
+
template (str): template string
|
|
290
|
+
pat_idx (list): list of token indices
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
bool: True if tokens in l match those in template
|
|
309
294
|
"""
|
|
310
295
|
if len(l.split())!=len(template.split()): return
|
|
311
296
|
return all([l.split()[t]==template.split()[t] for t in pat_idx])
|
|
312
297
|
|
|
313
298
|
def _parse_data(dat,l,idx_dict):
|
|
314
|
-
"""
|
|
315
|
-
|
|
316
|
-
:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
:param idx_dict: dictionary of column-name:(type-converter,token-index)
|
|
321
|
-
:type idx_dict: dict
|
|
299
|
+
"""Parses data in a matching line.
|
|
300
|
+
|
|
301
|
+
Args:
|
|
302
|
+
dat (pd.DataFrame): pandas dataframe
|
|
303
|
+
l (str): line
|
|
304
|
+
idx_dict (dict): dictionary of column-name:(type-converter,token-index)
|
|
322
305
|
"""
|
|
323
306
|
tok=l.split()
|
|
324
307
|
for k,v in idx_dict.items():
|
|
@@ -326,12 +309,11 @@ def _parse_data(dat,l,idx_dict):
|
|
|
326
309
|
dat[k].append(conv(tok[s]))
|
|
327
310
|
|
|
328
311
|
def diagnostics_graphs(logfiles,filename,**kwargs):
|
|
329
|
-
"""
|
|
312
|
+
"""Extracts selected data from the diagnostic output and generates plots.
|
|
330
313
|
|
|
331
|
-
:
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
:type filename: str
|
|
314
|
+
Args:
|
|
315
|
+
logfiles (list): list of names of diagnostic log files to treat in parallel
|
|
316
|
+
filename (str): name of output image file
|
|
335
317
|
"""
|
|
336
318
|
xmax=kwargs.get('xmax',-1)
|
|
337
319
|
figsize=kwargs.get('figsize',(12,6))
|
|
@@ -383,12 +365,13 @@ def diagnostics_graphs(logfiles,filename,**kwargs):
|
|
|
383
365
|
logging.disable(logging.NOTSET)
|
|
384
366
|
|
|
385
367
|
def init_molecule_graph(proj_dir):
|
|
386
|
-
"""
|
|
368
|
+
"""Creates and initializes an inter-molecular graph to show network connectivity.
|
|
369
|
+
|
|
370
|
+
Args:
|
|
371
|
+
proj_dir (str): name of project directory
|
|
387
372
|
|
|
388
|
-
:
|
|
389
|
-
|
|
390
|
-
:return: a nodes-only Graph enumerating all molecules; this will be further processed elsewhere to add connectivity information
|
|
391
|
-
:rtype: networkx.Graph
|
|
373
|
+
Returns:
|
|
374
|
+
networkx.Graph: a nodes-only Graph enumerating all molecules; this will be further processed elsewhere to add connectivity information
|
|
392
375
|
"""
|
|
393
376
|
gro=os.path.join(proj_dir,'systems/init/init.gro')
|
|
394
377
|
top=os.path.join(proj_dir,'systems/init/init.top')
|
|
@@ -402,14 +385,12 @@ def init_molecule_graph(proj_dir):
|
|
|
402
385
|
return G
|
|
403
386
|
|
|
404
387
|
def plots(args):
|
|
405
|
-
"""
|
|
388
|
+
"""Handles the plots subcommand.
|
|
406
389
|
|
|
407
|
-
:
|
|
408
|
-
|
|
390
|
+
Args:
|
|
391
|
+
args (argparse.Namespace): command-line arguments
|
|
409
392
|
"""
|
|
410
|
-
|
|
411
|
-
logging.basicConfig(format='%(levelname)s> %(message)s',level=loglevel_numeric)
|
|
412
|
-
if not args.no_banner: banner(logger.info)
|
|
393
|
+
setup_logging(args.loglevel, no_banner=args.no_banner)
|
|
413
394
|
|
|
414
395
|
if args.source=='build':
|
|
415
396
|
build_plots(args)
|