-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make VACF test work with MockTrajectory
- Loading branch information
1 parent
05a4db2
commit e804586
Showing
7 changed files
with
120 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
MDANSE/Src/MDANSE/Framework/Configurators/MockTrajectoryConfigurator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# ************************************************************************** | ||
# | ||
# MDANSE: Molecular Dynamics Analysis for Neutron Scattering Experiments | ||
# | ||
# @file Src/Framework/Configurators/MDMCTrajectoryConfigurator.py | ||
# @brief A way to take in a trajectory from MDMC in a wrapper | ||
# | ||
# @homepage https://www.isis.stfc.ac.uk/Pages/MDANSEproject.aspx | ||
# @license GNU General Public License v3 or higher (see LICENSE) | ||
# @copyright Institut Laue Langevin 2013-now | ||
# @copyright ISIS Neutron and Muon Source, STFC, UKRI 2021-now | ||
# @authors Scientific Computing Group at ILL (see AUTHORS) | ||
# | ||
# ************************************************************************** | ||
|
||
import os | ||
|
||
from MDANSE.Framework.Configurators.IConfigurator import IConfigurator | ||
from MDANSE.MolecularDynamics.MockTrajectory import MockTrajectory | ||
|
||
|
||
class MockTrajectoryConfigurator(IConfigurator): | ||
""" | ||
This is a replacement for a trajectory stored in and HDF5 file. | ||
It is intended to be a drop-in replacement for HDFTrajectoryConfigurator, | ||
even though it is NOT file-based. | ||
""" | ||
|
||
_default = None | ||
|
||
def __init__(self, name, wildcard="JSON file|*.json", **kwargs): | ||
""" | ||
Initializes the configurator object. | ||
:param name: the name of the configurator as it will appear in the configuration. | ||
:type name: str | ||
:param wildcard: the wildcard used to filter the file. This will be used in MDANSE GUI when | ||
browsing for the input file. | ||
:type wildcard: str | ||
""" | ||
|
||
# The base class constructor. | ||
IConfigurator.__init__(self, name, **kwargs) | ||
|
||
self._wildcard = wildcard | ||
|
||
def configure(self, value: str): | ||
""" | ||
Configure a mock trajectory file. | ||
:param value: a JSON file with a MockTrajectory definition | ||
:type value: str | ||
""" | ||
|
||
self["value"] = value | ||
self["filename"] = "Mock" | ||
|
||
self["instance"] = MockTrajectory.from_json(value) | ||
|
||
self["basename"] = "Mock" | ||
|
||
self["length"] = len(self["instance"]) | ||
|
||
self["md_time_step"] = self["instance"]._time_step | ||
|
||
self["has_velocities"] = self["instance"].has_velocities | ||
|
||
def get_information(self): | ||
""" | ||
Returns some basic informations about the contents of the HDF trajectory file. | ||
:return: the informations about the contents of the HDF trajectory file. | ||
:rtype: str | ||
""" | ||
|
||
info = ["Mock trajectory used as input"] | ||
info.append("Number of steps: %d\n" % self["length"]) | ||
info.append( | ||
"Size of the chemical system: %d\n" | ||
% self["instance"].chemical_system.number_of_atoms | ||
) | ||
if self["has_velocities"]: | ||
info.append("The trajectory contains atomic velocities\n") | ||
else: | ||
info.append("The trajectory does not contain atomic velocities\n") | ||
|
||
return "".join(info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters