From fdf23698021ea47523a187a3d23ea97913c6eeb1 Mon Sep 17 00:00:00 2001 From: jrudz Date: Mon, 12 Aug 2024 14:32:07 +0200 Subject: [PATCH 1/9] added shear flow parameters --- .../molecular_dynamics.py | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index 857b680..3f6ee0b 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -1564,6 +1564,68 @@ class BarostatParameters(ArchiveSection): ) +class ShearFlowParameters(ArchiveSection): + """ + Section containing the parameters pertaining to the shear flow for a molecular dynamics run. + """ + + m_def = Section(validate=False) + + shear_type = Quantity( + type=MEnum('lees_edwards', 'trozzi_ciccotti', 'ashurst_hoover'), + shape=[], + description=""" + The name of the method used to implement the effect of shear flow within the simulation. + + Allowed values are: + + | Shear Method | Description | + + | ---------------------- | ----------------------------------------- | + + | `""` | No thermostat | + + | `"lees_edwards"` | A.W. Lees and S.F. Edwards, + [J. Phys. C **5** (1972) 1921](https://doi.org/10.1088/0022-3719/5/15/006)| + + | `"trozzi_ciccotti"` | A.W. Lees and S.F. Edwards, + [Phys. Rev. A **29** (1984) 916](https://doi.org/10.1103/PhysRevA.29.916)| + + | `"ashurst_hoover"` | W. T. Ashurst and W. G. Hoover, + [Phys. Rev. A **11** (1975) 658](https://doi.org/10.1103/PhysRevA.11.658)| + """, + ) + + shear_rate = Quantity( + type=np.float64, + shape=[3, 3], + unit='ps^-1', + description=""" + The external stress tensor include normal (diagonal elements; which are zero in shear simulations) + and shear stress' rates (off-diagonal elements). + Its elements are: [[σ_x, τ_yx, τ_zx], [τ_xy, σ_y, τ_zy], [τ_xz, τ_yz, σ_z]], + where σ and τ are the normal and shear stress' rates. + The first and second letters in the index correspond to the normal vector to the shear plane and the direction of shearing, respectively. + """, + ) + + step_start = Quantity( + type=int, + shape=[], + description=""" + Trajectory step where this shearing starts. + """, + ) + + step_end = Quantity( + type=int, + shape=[], + description=""" + Trajectory step number where this shearing ends. + """, + ) + + class Lambdas(ArchiveSection): """ Section for storing all lambda parameters for free energy perturbation @@ -1834,6 +1896,10 @@ class MolecularDynamicsMethod(SimulationWorkflowMethod): barostat_parameters = SubSection(sub_section=BarostatParameters.m_def, repeats=True) + shear_flow_parameters = SubSection( + sub_section=ShearFlowParameters.m_def, repeats=True + ) + free_energy_calculation_parameters = SubSection( sub_section=FreeEnergyCalculationParameters.m_def, repeats=True ) From 883708838ffaad764d8258fc345ce702edd09234 Mon Sep 17 00:00:00 2001 From: jrudz Date: Fri, 16 Aug 2024 14:05:40 +0200 Subject: [PATCH 2/9] fixed rg issue --- simulationworkflowschema/molecular_dynamics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index 3f6ee0b..c205caf 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2203,7 +2203,7 @@ class RadiusOfGyration(TrajectoryProperty): atomsgroup_ref = Quantity( type=Reference(AtomsGroup.m_def), - shape=[1], + shape=[], description=""" References to the atoms_group section containing the molecule for which Rg was calculated. """, From b6efdeb18a543ee85b3e59240e3cf8cfb04769ef Mon Sep 17 00:00:00 2001 From: jrudz Date: Mon, 19 Aug 2024 14:36:55 +0200 Subject: [PATCH 3/9] rg atomsgroup_ref now stored as a list --- simulationworkflowschema/molecular_dynamics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index c205caf..3f6ee0b 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2203,7 +2203,7 @@ class RadiusOfGyration(TrajectoryProperty): atomsgroup_ref = Quantity( type=Reference(AtomsGroup.m_def), - shape=[], + shape=[1], description=""" References to the atoms_group section containing the molecule for which Rg was calculated. """, From cc842686ec3b4359a1e33b23f8d06e7fb25cf674 Mon Sep 17 00:00:00 2001 From: jrudz Date: Wed, 21 Aug 2024 14:40:45 +0200 Subject: [PATCH 4/9] renamed shear_parameters --- simulationworkflowschema/molecular_dynamics.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index 3f6ee0b..8808701 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -1564,7 +1564,7 @@ class BarostatParameters(ArchiveSection): ) -class ShearFlowParameters(ArchiveSection): +class ShearParameters(ArchiveSection): """ Section containing the parameters pertaining to the shear flow for a molecular dynamics run. """ @@ -1896,9 +1896,7 @@ class MolecularDynamicsMethod(SimulationWorkflowMethod): barostat_parameters = SubSection(sub_section=BarostatParameters.m_def, repeats=True) - shear_flow_parameters = SubSection( - sub_section=ShearFlowParameters.m_def, repeats=True - ) + shear_parameters = SubSection(sub_section=ShearParameters.m_def, repeats=True) free_energy_calculation_parameters = SubSection( sub_section=FreeEnergyCalculationParameters.m_def, repeats=True From 5251e48de56f601e7ccc303438f1e43c735984b5 Mon Sep 17 00:00:00 2001 From: jrudz Date: Thu, 29 Aug 2024 12:02:59 +0200 Subject: [PATCH 5/9] re-implemented rg as list --- simulationworkflowschema/molecular_dynamics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index 8808701..cf3522d 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2224,7 +2224,7 @@ def normalize(self, archive, logger): self.label = self._rg_results.get('label') # TODO Fix this assignment fails with TypeError try: - self.atomsgroup_ref = self._rg_results.get('atomsgroup_ref') + self.atomsgroup_ref = [self._rg_results.get('atomsgroup_ref')] except Exception: pass self.n_frames = self._rg_results.get('n_frames') @@ -2636,7 +2636,7 @@ def normalize(self, archive, logger): ) # TODO Fix this assignment fails with TypeError try: - sec_rg_values.atomsgroup_ref = rg.get('atomsgroup_ref') + sec_rg_values.atomsgroup_ref = [rg.get('atomsgroup_ref')] except Exception: pass sec_rg_values.label = rg.get('label') From 9e57ed32a4fb22659ff4a609231eaca34cce0b97 Mon Sep 17 00:00:00 2001 From: jrudz Date: Thu, 29 Aug 2024 13:34:56 +0200 Subject: [PATCH 6/9] print test --- simulationworkflowschema/molecular_dynamics.py | 1 + 1 file changed, 1 insertion(+) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index cf3522d..f3f81d0 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2634,6 +2634,7 @@ def normalize(self, archive, logger): sec_rg_values = sec_rgs_calc.m_create( RadiusOfGyrationValuesCalculation ) + print('in Rg normalize') # TODO Fix this assignment fails with TypeError try: sec_rg_values.atomsgroup_ref = [rg.get('atomsgroup_ref')] From 12167c8c08624826b38bad0956d2330a5c5bff6d Mon Sep 17 00:00:00 2001 From: jrudz Date: Wed, 4 Sep 2024 10:56:03 +0200 Subject: [PATCH 7/9] added try to archive_to_universe for MD results norm --- simulationworkflowschema/molecular_dynamics.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index f3f81d0..2218274 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2543,7 +2543,14 @@ class MolecularDynamicsResults(ThermodynamicsResults): def normalize(self, archive, logger): super().normalize(archive, logger) - universe = archive_to_universe(archive) + try: + universe = archive_to_universe(archive) + except Exception: + universe = None + logger.warning( + 'Could not convert archive to MDAnalysis Universe, skipping MD results normalization.' + ) + if universe is None: return @@ -2634,7 +2641,7 @@ def normalize(self, archive, logger): sec_rg_values = sec_rgs_calc.m_create( RadiusOfGyrationValuesCalculation ) - print('in Rg normalize') + # TODO Fix this assignment fails with TypeError try: sec_rg_values.atomsgroup_ref = [rg.get('atomsgroup_ref')] From 87058bc66dc217341e27c007c130b81602f78bb1 Mon Sep 17 00:00:00 2001 From: jrudz Date: Fri, 13 Sep 2024 14:51:45 +0200 Subject: [PATCH 8/9] added missing units --- .../molecular_dynamics.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index 2218274..ef1ad35 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2267,18 +2267,19 @@ class FreeEnergyCalculations(TrajectoryProperty): """, ) - value_unit = Quantity( - type=str, - shape=[], - description=""" - Unit of the property, using UnitRegistry() notation. - In this case, the unit corresponds to all `value` properties stored within this section. - """, - ) + # value_unit = Quantity( + # type=str, + # shape=[], + # description=""" + # Unit of the property, using UnitRegistry() notation. + # In this case, the unit corresponds to all `value` properties stored within this section. + # """, + # ) value_total_energy_magnitude = Quantity( type=HDF5Dataset, shape=[], + unit='joule', description=""" Value of the total energy for the present lambda state. The expected dimensions are ["n_frames"]. This quantity is a reference to the data (file+path), which is stored in an HDF5 file for efficiency. @@ -2288,6 +2289,7 @@ class FreeEnergyCalculations(TrajectoryProperty): value_PV_energy_magnitude = Quantity( type=HDF5Dataset, shape=[], + unit='joule', description=""" Value of the pressure-volume energy (i.e., P*V) for the present lambda state. The expected dimensions are ["n_frames"]. This quantity is a reference to the data (file+path), which is stored in an HDF5 file for efficiency. @@ -2297,6 +2299,7 @@ class FreeEnergyCalculations(TrajectoryProperty): value_total_energy_differences_magnitude = Quantity( type=HDF5Dataset, shape=[], + unit='joule', description=""" Values correspond to the difference in total energy between each specified lambda state and the reference state, which corresponds to the value of lambda of the current simulation. @@ -2308,6 +2311,7 @@ class FreeEnergyCalculations(TrajectoryProperty): value_total_energy_derivative_magnitude = Quantity( type=HDF5Dataset, shape=[], + unit='joule', # TODO check this unit description=""" Value of the derivative of the total energy with respect to lambda, evaluated for the current lambda state. The expected dimensions are ["n_frames"]. From 3272ba9d5c6daa2cc7bf068c13ed74300f26e02c Mon Sep 17 00:00:00 2001 From: jrudz Date: Mon, 16 Sep 2024 13:00:06 +0200 Subject: [PATCH 9/9] remove comments --- simulationworkflowschema/molecular_dynamics.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/simulationworkflowschema/molecular_dynamics.py b/simulationworkflowschema/molecular_dynamics.py index ef1ad35..4cfc4f2 100644 --- a/simulationworkflowschema/molecular_dynamics.py +++ b/simulationworkflowschema/molecular_dynamics.py @@ -2267,15 +2267,6 @@ class FreeEnergyCalculations(TrajectoryProperty): """, ) - # value_unit = Quantity( - # type=str, - # shape=[], - # description=""" - # Unit of the property, using UnitRegistry() notation. - # In this case, the unit corresponds to all `value` properties stored within this section. - # """, - # ) - value_total_energy_magnitude = Quantity( type=HDF5Dataset, shape=[],