venuspython 1.0.0__tar.gz → 1.0.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: venuspython
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: VENUSpy Initial Sampling and Molecular Dynamics
5
5
  Keywords: moleculardynamics,initialsampling
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -0,0 +1,588 @@
1
+ from ase.io import read
2
+ from ase.md.verlet import VelocityVerlet
3
+ from ase import units
4
+
5
+ from ase.vibrations import Vibrations
6
+ import random
7
+
8
+ import argparse
9
+ import numpy as np
10
+ import os
11
+
12
+ import venuspy
13
+
14
+ # For initial sampling:
15
+ from venuspy.initialSampling import initialSampling
16
+
17
+ # For rewindrestarts:
18
+ from ase.io.extxyz import read_xyz
19
+
20
+ # For rewinds with sGDML:
21
+ from venuspy.md import regularMD, pingpongMD, smoothedMD, r2threshold
22
+
23
+
24
+
25
+ # Try importing BAGEL
26
+ try:
27
+ from venuspy.calc.bagelcalc import bagelcalculator
28
+ except ImportError:
29
+ print("WARNING: BAGEL has not been loaded ... it will not be available for initial sampling")
30
+
31
+ # Try importing psi4
32
+ try:
33
+ from venuspy.calc.psi4calc import psi4calculator
34
+ except ImportError:
35
+ print("WARNING: psi4 has not been loaded ... it will not be available for initial sampling")
36
+
37
+ # Try importing xtb (fast, semi-empirical DFT):
38
+ try:
39
+ # from tblite.ase import TBLite
40
+ from venuspy.calc.xtbcalc import TBLite
41
+ except ImportError:
42
+ print("WARNING: xtb has not been loaded ... it will not be available for initial sampling")
43
+
44
+ # Try import NWChem (not NWChemEx)
45
+ #from nwchemcalc import nwchemcalculator
46
+ try:
47
+ from venuspy.calc.nwchemcalc import nwchemcalculator
48
+ except ImportError:
49
+ print("WARNING: NWChem has not been loaded ... it will not be available for initial sampling")
50
+
51
+ # Try importing NWChemEx
52
+ try:
53
+ from venuspy.calc.nwchemexcalc import nwchemexcalculator
54
+ except ImportError:
55
+ print("WARNING: NWChemEx has not been loaded ... it will not be available for initial sampling")
56
+
57
+ # Try importing QCEngine/GAMESS
58
+ try:
59
+ from venuspy.calc.qcengineGAMESScalc import qcengineGAMESScalculator
60
+ except ImportError:
61
+ print("WARNING: QCEngine/GAMESS has not been loaded ... it will not be available for initial sampling")
62
+
63
+ # Try importing sGDML
64
+ try:
65
+ import sgdml
66
+ from sgdml.train import GDMLTrain
67
+ from sgdml.predict import GDMLPredict
68
+ from sgdml.intf.ase_calc import SGDMLCalculator
69
+
70
+ from venuspy.calc.minisgdmlcalc import miniSGDMLCalculator
71
+
72
+ except ImportError:
73
+ print("WARNING: sGDML has not been loaded ... it will not be available for initial sampling")
74
+
75
+ # Try importing chempotpy
76
+ try:
77
+ from venuspy.calc.chempotpycalc import chempotpyCalculator
78
+ except ImportError:
79
+ print("WARNING: chempotpy has not been loaded ... it will not be available for initial sampling")
80
+
81
+ # Try importing Schnet
82
+ try:
83
+ import schnetpack as spk
84
+ import torch
85
+ except ImportError:
86
+ print("WARNING: Schnet has not been loaded ... it will not be available for initial sampling")
87
+
88
+ # Try importing Physnet
89
+ try:
90
+ from venuspy.calc.physnetcalc import PNCalculator
91
+ except ImportError:
92
+ print("WARNING: Physnet has not been loaded ... it will not be available for initial sampling")
93
+
94
+
95
+
96
+ ###################################################
97
+
98
+ # Define global constants up here in the correct
99
+ # units so that internally, everything uses:
100
+ # Energy: eV
101
+ # Distance: Angstrom
102
+ # Mass: Dalton
103
+
104
+ # global r2threshold
105
+
106
+ ###################################################
107
+
108
+ parser = argparse.ArgumentParser(description="Do a single MD trajectory using a initial geometry (and momenta) and a sGDML model",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
109
+ parser.add_argument("initialGeometryFile", type=str, help="XYZ file with initial geometry; if initial conditions are sampled in the script, then this argument is required but is just an example XYZ")
110
+ parser.add_argument("PESinputFile", type=str, help="PES input file (may be a psi4 input file or a sGDML .npz model)")
111
+ parser.add_argument("outputDir", type=str, help="Directory to output stuff in")
112
+ parser.add_argument("--isotopeMassesFile", type=str, help="Change masses of specific atoms e.g. like isotopic substitution", default=None)
113
+ parser.add_argument("--rewindrestartFile", type=str, help="EXYZ file of a previous trajectory to rewind-restart from",default=None)
114
+ parser.add_argument("--rewindrestartEnergyThreshold", type=float, help="The energy threshold for allowable energy jumps to rewind-restart from",default=0.50)
115
+ parser.add_argument("--rewindrestartNskip", type=int, help="The number of frames at the end of the trajectory to skip possible restarts from",default=0)
116
+ parser.add_argument("--initialMomentaFile", type=str, help="XYZ file with initial momenta")
117
+ parser.add_argument("--atomsInFirstGroup", type=str, help="String with atoms which are in first group of atoms, separated by spaces")
118
+ parser.add_argument("--collisionEnergy", type=float, help="Collision energy in kcal/mol")
119
+ parser.add_argument("--impactParameter", type=float, help="Impact parameter in Angstrom")
120
+ parser.add_argument("--centerOfMassDistance", type=float, help="Distance between the two molecules' centers of mass in Angstrom")
121
+ #parser.add_argument('--optimize', action=argparse.BooleanOptionalAction, default=True)
122
+ parser.add_argument('--optimize', type=bool, default=True)
123
+ parser.add_argument("--production", type=int, help="Supply number of steps for a production run")
124
+ parser.add_argument("--interval", type=int, help="How often to print out the energy")
125
+ parser.add_argument("--time_step", type=float, help="The time step in fs for a production run")
126
+ parser.add_argument("--MDtype", type=str, help="The type of molecular dynamics to do: 'regular', 'pingpong', or 'smoothed' with sGDML", default="regular")
127
+ parser.add_argument("--Nrewindsteps", type=int, help="The number of steps to use MLMD for when smoothing",default=4)
128
+ parser.add_argument("--dEmax", type=float, help="The maximum change in total energy allowed between consecutive steps",default=1.0)
129
+ parser.add_argument("--Edriftmax", type=float, help="The maximum change in total energy allowed from start to end",default=1.5)
130
+ parser.add_argument("--E0", type=float, help="The initial total energy to track the drift in total energy (e.g. if the trajectory is being restarted)",default=None)
131
+ parser.add_argument("--n_threads", type=int, help="The number of threads to ask psi4 to use")
132
+
133
+ parser.add_argument("--INITQPa", type=str, help="Initial sampling method for atoms in first group ('semiclassical', 'microcanonical', 'thermal', or None)", default="")
134
+ parser.add_argument("--NVIBa", type=int, help="Vibrational quantum number of atoms in first group (supply if using the 'semiclassical' initial sampling)")
135
+ parser.add_argument("--NROTa", type=int, help="Rotational quantum number of atoms in first group (supply if using the 'semiclassical' initial sampling)")
136
+ parser.add_argument("--EVIBa", type=float, help="Vibrational energy of atoms in first group (supply if using the 'microcanonical' initial sampling)")
137
+ parser.add_argument("--EROTa", type=float, help="Rotational energy of atoms in first group (supply if using the 'microcanonical' initial sampling)")
138
+ parser.add_argument("--TVIBa", type=float, help="Vibrational temperature of atoms in first group (supply if using the 'thermal' initial sampling)")
139
+ parser.add_argument("--TROTa", type=float, help="Rotational temperature of atoms in first group (supply if using the 'thermal' initial sampling)")
140
+
141
+ parser.add_argument("--INITQPb", type=str, help="Initial sampling method for atoms in second group ('semiclassical', 'microcanonical', 'thermal', or None)", default="")
142
+ parser.add_argument("--NVIBb", type=int, help="Vibrational quantum number of atoms in second group (supply if using the 'semiclassical' initial sampling)")
143
+ parser.add_argument("--NROTb", type=int, help="Rotational quantum number of atoms in second group (supply if using the 'semiclassical' initial sampling)")
144
+ parser.add_argument("--EVIBb", type=float, help="Vibrational energy of atoms in second group (supply if using the 'microcanonical' initial sampling)")
145
+ parser.add_argument("--EROTb", type=float, help="Rotational energy of atoms in second group (supply if using the 'microcanonical' initial sampling)")
146
+ parser.add_argument("--TVIBb", type=float, help="Vibrational temperature of atoms in second group (supply if using the 'thermal' initial sampling)")
147
+ parser.add_argument("--TROTb", type=float, help="Rotational temperature of atoms in second group (supply if using the 'thermal' initial sampling)")
148
+ args = vars(parser.parse_args())
149
+
150
+ ########################################################################################
151
+
152
+ # A function to print the potential, kinetic and total energy
153
+ def printenergy(a,step,energyflag):
154
+ if ("ERROR" in energyflag):
155
+ epot = 0.0
156
+ ekin = a.get_kinetic_energy() / (units.kcal/units.mol)
157
+ print('@Epot = %.3f Ekin = %.3f (T=%3.0fK) '
158
+ 'Etot = %.3f kcal/mol Step = %8d %s' % (epot, ekin, ekin / (len(a) * 1.5 * 8.617281e-5), epot + ekin, step, energyflag))
159
+ else:
160
+ epot = a.get_potential_energy() / (units.kcal/units.mol)
161
+ ekin = a.get_kinetic_energy() / (units.kcal/units.mol)
162
+ print('@Epot = %.3f Ekin = %.3f (T=%3.0fK) '
163
+ 'Etot = %.3f kcal/mol Step = %8d %s' % (epot, ekin, ekin / (len(a) * 1.5 * 8.617281e-5), epot + ekin, step, energyflag))
164
+
165
+ ########################################################################################
166
+
167
+ # Get the various arguments
168
+ Qfile = args["initialGeometryFile"]
169
+ input_path = args["PESinputFile"]
170
+ output_path = args["outputDir"]
171
+
172
+ rrQPfile = args["rewindrestartFile"]
173
+ rrQPdEmax = args["rewindrestartEnergyThreshold"]
174
+ rrNskip = args["rewindrestartNskip"]
175
+
176
+ Pfile = args["initialMomentaFile"]
177
+ atomsInFirstGroup = args["atomsInFirstGroup"]
178
+ ce = args["collisionEnergy"]
179
+ b = args["impactParameter"]
180
+ dCM = args["centerOfMassDistance"]
181
+
182
+ isotopeMassesFile = args["isotopeMassesFile"]
183
+ Nsteps = args["production"]
184
+ Nprint = args["interval"]
185
+ dt = args["time_step"]
186
+
187
+ MDtype = args["MDtype"]
188
+ dEmax = args["dEmax"]
189
+ Edriftmax = args["Edriftmax"]
190
+ E0= args["E0"]
191
+ Nrewindsteps = args["Nrewindsteps"]
192
+
193
+ optimize_flag = args["optimize"]
194
+
195
+ if ((Nsteps is None) or (Nprint is None) or (dt is None)):
196
+ raise ValueError("For MD, need to specify these three: --production --interval --time_step")
197
+
198
+ n_threads = args["n_threads"]
199
+ if (n_threads is None): n_threads = 1
200
+
201
+ samplingMethod = [ args["INITQPa"], args["INITQPb"] ]
202
+ vibrationSampling = []
203
+ rotationSampling = []
204
+ if (samplingMethod[0] == "semiclassical"):
205
+ vibrationSampling.append(args["NVIBa"])
206
+ rotationSampling.append(args["NROTa"])
207
+ elif ("microcanonical" in samplingMethod[0]):
208
+ vibrationSampling.append(args["EVIBa"])
209
+ rotationSampling.append(args["EROTa"])
210
+ else:
211
+ vibrationSampling.append(args["TVIBa"])
212
+ rotationSampling.append(args["TROTa"])
213
+ if (samplingMethod[1] == "semiclassical"):
214
+ vibrationSampling.append(args["NVIBb"])
215
+ rotationSampling.append(args["NROTb"])
216
+ elif ("microcanonical" in samplingMethod[1]):
217
+ vibrationSampling.append(args["EVIBb"])
218
+ rotationSampling.append(args["EROTb"])
219
+ else:
220
+ vibrationSampling.append(args["TVIBb"])
221
+ rotationSampling.append(args["TROTb"])
222
+
223
+ # Note:
224
+ # Right now, all arguments are mandatory (even though this does
225
+ # not raise a warning) except for isotopeMassesFile
226
+
227
+ # Adjust the maximum interatomic distance allowed
228
+ # for the simulation
229
+ if ((b is not None) and (dCM is not None) and (1.2*(b**2 + dCM**2) > r2threshold)):
230
+ r2threshold = 1.2*(b**2 + dCM**2)
231
+
232
+ ########################################################################################
233
+
234
+ # Look at the input file name to guess its identity
235
+ try_bagel = False
236
+ try_psi4 = False
237
+ try_xtb = False
238
+ try_mopac = False
239
+ try_chempotpy = False
240
+ try_nwchem = False
241
+ try_nwchemex = False
242
+ try_physnet = False
243
+ try_schnet = False
244
+ try_sgdml = False
245
+ try_qcenginegamess = False
246
+ if (input_path.endswith(('.npz',))):
247
+
248
+ print("Input file '"+input_path+"' looks like a sGDML file so will attempt to read it in as such...")
249
+ try:
250
+ calc = SGDMLCalculator(input_path)
251
+ try_sgdml = True
252
+ # try_psi4 = False
253
+ except:
254
+ print(" Could not load file '"+input_path+"' as a sGDML model!")
255
+ try_psi4 = True
256
+
257
+ elif (input_path.endswith(('.physnet.config',))):
258
+ print("Input file '"+input_path+"' looks like a PhysNet config file so will attempt to read it in as such...")
259
+
260
+ # temporary:
261
+ # try:
262
+ if True:
263
+ tmp_mol = read(Qfile)
264
+ calc = PNCalculator(input_path,tmp_mol)
265
+ try_physnet = True
266
+
267
+ # except:
268
+ # print(" Could not load file '"+input_path+"' as a PhysNet model!")
269
+ # try_physnet = True
270
+
271
+ elif (input_path.endswith(('.bagel',))):
272
+ try_bagel = True
273
+
274
+ elif (input_path.endswith(('.psi4',))):
275
+ try_psi4 = True
276
+
277
+ elif (input_path.endswith(('.nwchem',))):
278
+ try_nwchem = True
279
+
280
+ elif (input_path.endswith(('.chempotpy',))):
281
+ try_chempotpy = True
282
+
283
+ elif (input_path.endswith(('.xtb',))):
284
+ try_xtb = True
285
+
286
+ elif (input_path.endswith(('.mopac',))):
287
+ try_mopac = True
288
+
289
+ elif (input_path.endswith(('.gamess.qcengine',))):
290
+ try_qcenginegamess = True
291
+
292
+ elif (input_path.endswith(('.nwchemex',))):
293
+ try_nwchemex = True
294
+
295
+ else:
296
+ try_schnet = True
297
+
298
+
299
+
300
+
301
+ if (try_schnet):
302
+
303
+ # Initialize the ML ase interface
304
+
305
+ # To accomodate for the older versions of numpy used in Schnet==1.0
306
+ np.int = np.int32
307
+ np.float = np.float64
308
+ np.bool = np.bool_
309
+
310
+ calc = spk.interfaces.SpkCalculator(
311
+ input_path,
312
+ device="cpu",
313
+ energy="energy", # Name of energies
314
+ forces="forces", # Name of forces
315
+ energy_units="kcal/mol",
316
+ forces_units="kcal/mol/A",
317
+ neighbor_list=spk.transform.ASENeighborList(5.0),
318
+ )
319
+
320
+
321
+ if (try_bagel):
322
+ print("Reading input file '"+input_path+"' as a BAGEL input file...")
323
+ calc = bagelcalculator(custominputfile=input_path,command='mpirun /mnt/lustre/koa/koastore/rsun_group/camels/BAGEL_1_AV/BAGEL/bin/BAGEL bagel0.json > bagel0.out')
324
+
325
+ # calc.restarts_max = 2 # Max number of allowable SCF restarts
326
+
327
+ # To conform to VENUS, we are going to keep the units
328
+ # in kcal/mol and Angstroms (which the model was
329
+ # originally trained on)
330
+ calc.E_to_eV = units.Ha
331
+ calc.Ang_to_R = units.Ang
332
+ calc.F_to_eV_Ang = (units.Ha / units.Bohr)
333
+
334
+ if (try_psi4):
335
+ print("Reading input file '"+input_path+"' as a psi4 input file...")
336
+ calc = psi4calculator(input_path,n_threads=n_threads)
337
+
338
+ calc.restarts_max = 2 # Max number of allowable SCF restarts
339
+
340
+ # To conform to VENUS, we are going to keep the units
341
+ # in kcal/mol and Angstroms (which the model was
342
+ # originally trained on)
343
+ calc.E_to_eV = units.Ha
344
+ calc.Ang_to_R = units.Ang
345
+ calc.F_to_eV_Ang = (units.Ha / units.Bohr)
346
+
347
+ if (try_xtb):
348
+ print("Reading input file '"+input_path+"' as a xtb input file...")
349
+ calc = TBLite(input_path)
350
+
351
+ if (try_qcenginegamess):
352
+ print("Reading input file '"+input_path+"' as a QCEngine/GAMESS input file...")
353
+ calc = qcengineGAMESScalculator(input_path,n_threads=n_threads)
354
+
355
+ # To conform to VENUS, we are going to keep the units
356
+ # in kcal/mol and Angstroms (which the model was
357
+ # originally trained on)
358
+ calc.E_to_eV = units.Ha
359
+ calc.Ang_to_R = (units.Ang / units.Bohr)
360
+ calc.F_to_eV_Ang = (units.Ha / units.Bohr)
361
+
362
+ if (try_nwchemex):
363
+ print("Reading input file '"+input_path+"' as a NWChemEx input file...")
364
+ calc = nwchemexcalculator(input_path,output_path=output_path,n_threads=n_threads)
365
+
366
+ # To conform to VENUS, we are going to keep the units
367
+ # in kcal/mol and Angstroms (which the model was
368
+ # originally trained on)
369
+ calc.E_to_eV = units.Ha
370
+ calc.Ang_to_R = (units.Ang / units.Bohr)
371
+ calc.F_to_eV_Ang = (units.Ha / units.Bohr)
372
+
373
+ if (try_nwchem):
374
+ print("Reading input file '"+input_path+"' as a NWChem (not NWChemEx) input file...")
375
+ calc = nwchemcalculator(input_path,output_path=output_path,n_threads=n_threads)
376
+
377
+ # To conform to VENUS, we are going to keep the units
378
+ # in kcal/mol and Angstroms (which the model was
379
+ # originally trained on)
380
+ calc.E_to_eV = 1.0 # units.Ha
381
+ calc.Ang_to_R = 1.0 # (units.Ang / units.Bohr)
382
+ calc.F_to_eV_Ang = 1.0 # (units.Ha / units.Bohr)
383
+
384
+ if (try_chempotpy):
385
+
386
+ print("Reading input file '"+input_path+"' as a chempotpy input file...")
387
+
388
+ # Read the input file
389
+ with open(input_path, 'r') as f:
390
+
391
+ totallines = []
392
+ totalentries = []
393
+ for line in f:
394
+ strippedline=" ".join(line.split())
395
+ entries = strippedline.split(" ")
396
+ totallines.append(line)
397
+ totalentries = totalentries + entries
398
+
399
+ calc = chempotpyCalculator(totallines[0])
400
+ strippedline=" ".join(line.split()[2:])
401
+ print("Single state: {:s} - Chempotpy input: {:s}".format(totalentries[0],strippedline))
402
+
403
+ # Note, different chempotpy PES have different maximum allowed distances
404
+ # For O3 surfaces, 100 A is okay (= 2 * 50 A)
405
+ initialSampling.dSEPARATED = 50.0
406
+
407
+ # For now, just use a different distance threshold too
408
+ r2threshold = (dCM + 5.0) * (dCM + 5.0)
409
+
410
+
411
+ if (try_mopac):
412
+ print("Reading input file '"+input_path+"' as a MOPAC input file...")
413
+ calc = mopaccalculator(input_path,output_path=output_path)
414
+
415
+ # To conform to VENUS, we are going to keep the units
416
+ # in kcal/mol and Angstroms (which the model was
417
+ # originally trained on)
418
+ calc.E_to_eV = 1.0 # units.Ha
419
+ calc.Ang_to_R = 1.0 # (units.Ang / units.Bohr)
420
+ calc.F_to_eV_Ang = 1.0 # (units.Ha / units.Bohr)
421
+
422
+
423
+ # Read in the geometry; set it in the "calculator"
424
+ mol = read(Qfile)
425
+ mol.set_calculator(calc)
426
+ mol.calc = calc
427
+ mol._calc = calc
428
+
429
+ # Get the output trajectory file ready
430
+ trajfile = os.path.join(output_path, "production.traj")
431
+
432
+ # If the masses are given, update the masses
433
+ # Note: this must be done BEFORE setting the momenta
434
+ if not (isotopeMassesFile is None):
435
+ massFile = open(isotopeMassesFile,"r")
436
+ newMasses = massFile.readlines()
437
+ massFile.close()
438
+ if (len(newMasses) != len(mol)): #.masses)):
439
+ raise ValueError("Number of masses provided in the isotope mass file does not match the input XYZ")
440
+ mol.set_masses([float(i) for i in newMasses])
441
+
442
+ # If a rewind-restart file is given, read in the coordinates (Q),
443
+ # momenta (P), and energies, for a possible restart
444
+ if not (rrQPfile is None):
445
+
446
+ print("REWIND-RESTARTING using this file: " + rrQPfile)
447
+
448
+ # Look at the last 1500 frames to restart from (but skip the last rrNskip)
449
+ rrQPfilehandle = open(rrQPfile)
450
+ if (rrNskip <= 0):
451
+ rrmols = list(read_xyz(rrQPfilehandle,slice(-1500,None)))
452
+ rrNskip = 0
453
+ else:
454
+ rrmols = list(read_xyz(rrQPfilehandle,slice(-(1500+rrNskip),-rrNskip)))
455
+
456
+ rrQPflag = True
457
+ Nconsecutivegoodframes = 0
458
+ rrmols.reverse() # Go from the most-recent to least-recent
459
+ for i,rrmol in enumerate(rrmols):
460
+ mol.set_positions(rrmol.get_positions())
461
+ mol.set_velocities(rrmol.get_velocities())
462
+ mol.set_momenta(rrmol.get_momenta())
463
+
464
+ # Compare the original and restarted potential energies
465
+ E_original = rrmol.calc.results['energy']
466
+ try:
467
+ Nconsecutivegoodframes += 1
468
+ E_restart = mol.get_potential_energy()
469
+ dE = abs(E_original - E_restart) / (units.kcal/units.mol)
470
+ print("REWIND-RESTARTING sees that the %d-th to last frame (1-th to last = last frame) has original energy %.3f and restart energy %.3f kcal/mol"
471
+ % (rrNskip+i+1, E_original / (units.kcal/units.mol), E_restart / (units.kcal/units.mol)))
472
+ except:
473
+ Nconsecutivegoodframes = 0
474
+ dE = rrQPdEmax * 2
475
+ print("REWIND-RESTARTING sees that the %d-th to last frame (1-th to last = last frame) has original energy %.3f and restart energy NaN kcal/mol"
476
+ % (rrNskip+i+1, E_original / (units.kcal/units.mol)))
477
+
478
+ # If they agree within the threshold, then go ahead with the restart
479
+ if (dE < rrQPdEmax):
480
+
481
+ # For a smoothed MD simulation, we need a few frames at the start to buffer over
482
+ if (Nconsecutivegoodframes < 10):
483
+ if (MDtype == "smoothed"): continue
484
+
485
+ rrQPflag = False
486
+ print("REWIND-RESTARTING accepts using the %d-th to last frame! (1-th to last = last frame)" % (rrNskip+i+1,))
487
+ break
488
+
489
+ if (rrQPflag):
490
+ raise ValueError("REWIND-RESTARTING failed ... no acceptable frames to restart from")
491
+
492
+ # If a momenta file is given, read in the momenta
493
+ # Read it in as a geometry, and then set it into the molecule
494
+ elif not (Pfile is None):
495
+ frame = read(Pfile)
496
+ p = [atom.position for atom in frame]
497
+ mol.set_momenta(p)
498
+
499
+ masses=mol.get_masses()
500
+ v = [p[i]/masses[i] for i in range(len(p))]
501
+ mol.set_velocities(v)
502
+
503
+ # If there is no momenta file, then do initial sampling
504
+ else:
505
+
506
+ Natoms = len(mol)
507
+
508
+ # If no atoms are specified to be in the first group,
509
+ # assume that this is a unimolecular sampling
510
+ if (atomsInFirstGroup is None):
511
+ atomsInFirstGroup = range(Natoms)
512
+
513
+ atomsInFirstGroup = [int(i)-1 for i in atomsInFirstGroup.split()]
514
+
515
+ atomsInSecondGroup = []
516
+ for i in range(Natoms):
517
+ if (i not in atomsInFirstGroup): atomsInSecondGroup.append(i)
518
+
519
+ if ((len(atomsInFirstGroup) > 0) and (len(atomsInSecondGroup) > 0)):
520
+ bimolecular_flag = True
521
+ if ((ce is None) or (b is None) or (dCM is None)):
522
+ raise ValueError("Lacking an argument for bimolecular sampling (collision energy, impact parameter, of center of mass distance)")
523
+ else:
524
+ bimolecular_flag = False
525
+
526
+ print("")
527
+ print("GEOMETRY INPUT")
528
+ print(" Input geometry file: ", Qfile)
529
+ print("Atoms in first group: ", atomsInFirstGroup)
530
+ print("Atoms in second group: ", atomsInSecondGroup)
531
+ print("SAMPLING INPUT")
532
+ print(" Input momenta file: ", Pfile)
533
+ if (Pfile is None):
534
+ print(" Optimize molecules? ", optimize_flag)
535
+ print(" Group A sampling method: ", samplingMethod[0])
536
+ print(" Group A vibration: ", vibrationSampling[0])
537
+ print(" Group A rotation: ", rotationSampling[0])
538
+ print(" Group B sampling method: ", samplingMethod[1])
539
+ print(" Group B vibration: ", vibrationSampling[1])
540
+ print(" Group B rotation: ", rotationSampling[1])
541
+ print(" Impact parameter (A): ", b)
542
+ print(" Initial separation (A): ", dCM)
543
+ print(" Collsion energy (kcal/mol): ", ce)
544
+ else:
545
+ print(" Input momenta file: ", Pfile)
546
+
547
+ print("##############################################################")
548
+ print("")
549
+
550
+ # Sample the internal positions and momenta of each of
551
+ # the two molecules
552
+ sampler = initialSampling(mol,atomsInFirstGroup,optimize=optimize_flag,
553
+ optimization_file=os.path.join(output_path, "optimization.traj"),
554
+ samplingMethodA=samplingMethod[0],vibrationalSampleA=vibrationSampling[0],rotationalSampleA=rotationSampling[0],
555
+ samplingMethodB=samplingMethod[1],vibrationalSampleB=vibrationSampling[1],rotationalSampleB=rotationSampling[1])
556
+
557
+ print("Sampling internal degrees of freedom...")
558
+ sampler.sampleRelativeQP()
559
+
560
+ if (bimolecular_flag):
561
+ print("Sampling relative degrees of freedom...")
562
+ sampler.sampleAbsoluteQP(ce,dCM=dCM,b=b)
563
+
564
+ else:
565
+ sampler.centerMolecule(range(Natoms))
566
+
567
+ ########################################################################################
568
+
569
+ if (MDtype == "regular"):
570
+
571
+ MDgen = regularMD(mol,trajfile,dt,Nprint=Nprint)
572
+
573
+ elif (MDtype == "pingpong"):
574
+
575
+ MDgen = pingpongMD(mol,trajfile,dt,Nprint=Nprint)
576
+
577
+ elif (MDtype == "smoothed"):
578
+
579
+ # MDgen = smoothedMD(mol,trajfile,dt,Nprint=Nprint,Nrewindsteps=Nrewindsteps,dEmax=dEmax,Edriftmax=Edriftmax)
580
+ MDgen = smoothedMD(mol,trajfile,dt,Nprint=Nprint,Nrewindsteps=Nrewindsteps,dEmax=dEmax,Edriftmax=Edriftmax,E0=E0,n_threads=n_threads)
581
+
582
+ else:
583
+ raise ValueError("MD type '"+MDtype+"' is not valid! Exiting...")
584
+
585
+ MDgen.production(Nsteps)
586
+
587
+
588
+
@@ -26,8 +26,11 @@ version = {attr = "venuspy.__version__"}
26
26
  [tool.setuptools.packages.find]
27
27
  where = ["."] # list of folders that contain the packages (["."] by default)
28
28
  include = ["venuspy"] # package names should match these glob patterns (["*"] by default)
29
- exclude = ["images", "examples"] # exclude packages matching these glob patterns (empty by default)
29
+ exclude = ["*images*", "*examples*"] # exclude packages matching these glob patterns (empty by default)
30
30
  namespaces = false # to disable scanning PEP 420 namespaces (true by default)
31
31
 
32
32
  [project.scripts]
33
33
  venuspy-cli = "venuspy:cli"
34
+
35
+ [tool.setuptools.package-data]
36
+ myModule = ["images/*"]
@@ -0,0 +1 @@
1
+ __version__ = "1.0.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: venuspython
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: VENUSpy Initial Sampling and Molecular Dynamics
5
5
  Keywords: moleculardynamics,initialsampling
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -1,4 +1,5 @@
1
1
  README.md
2
+ cli.py
2
3
  pyproject.toml
3
4
  venuspy/__init__.py
4
5
  venuspy/initialSampling.py
@@ -1 +0,0 @@
1
- __version__ = "1.0.0"
File without changes
File without changes
File without changes