Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unit-based protocol options to be passed as strings #179

Merged
merged 9 commits into from
Oct 11, 2023

Conversation

lohedges
Copy link
Contributor

@lohedges lohedges commented Oct 3, 2023

This PR enables unit-based protocol options to be passed as strings, e.g:

# These are equivalent.

# Instantiate from types.
p0 = BSS.Protocol.Equilibration(
    timestep=1 * BSS.Units.Time.femtosecond,
    runtime=100 * BSS.Units.Time.picosecond,
    temperature_start=0 * BSS.Units.Temperature.kelvin,
    temperature_end=298 * BSS.Units.Temperature.kelvin,
    pressure=1 * BSS.Units.Pressure.atm,
    restraint="backbone",
    force_constant=100
    * BSS.Units.Energy.kj_per_mol
    / BSS.Units.Length.nanometer**2,
)

# Instantiate from strings.
p1 = BSS.Protocol.Equilibration(
    timestep="1fs",
    runtime="100ps",
    temperature_start="0K",
    temperature_end="298K",
    pressure="1atm",
    restraint="backbone",
    force_constant="100 kJ / (mol nm^2)",
)

This means less typing and makes it easier to instantiate a protocol using settings in a configuration file. (Although none of this is a problem if using nodes.) There are other places in the code where the same approach could be applied, but this is the main point of friction. (I'll update the others as I refactor other parts.)

I've taken the opportunity to add some equality operators to make the testing easier. A lot of the changes are boiler-plate around that.

  • I confirm that I have merged the latest version of devel into this branch before issuing this pull request (e.g. by running git pull origin devel): [y]
  • I confirm that I have added a test for any new functionality in this pull request: [y]
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: [y]
  • I confirm that I have permission to release this code under the GPL3 license: [y]

Suggested reviewers:

@chryswoods

@lohedges lohedges added the enhancement New feature or request label Oct 3, 2023
@lohedges lohedges requested a review from chryswoods October 3, 2023 10:50
@lohedges lohedges temporarily deployed to biosimspace-build October 3, 2023 10:50 — with GitHub Actions Inactive
@lohedges lohedges temporarily deployed to biosimspace-build October 3, 2023 10:50 — with GitHub Actions Inactive
@lohedges lohedges temporarily deployed to biosimspace-build October 3, 2023 10:50 — with GitHub Actions Inactive
@lohedges lohedges temporarily deployed to biosimspace-build October 3, 2023 10:50 — with GitHub Actions Inactive
@lohedges lohedges temporarily deployed to biosimspace-build October 3, 2023 10:50 — with GitHub Actions Inactive
@lohedges
Copy link
Contributor Author

lohedges commented Oct 3, 2023

(I clearly took inspiration from the Sire dynamics code.)

Copy link
Contributor

@chryswoods chryswoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look good. I'm pleased that sire.u was useful :-)

@lohedges lohedges merged commit 85c71bc into devel Oct 11, 2023
5 checks passed
@lohedges lohedges deleted the feature_string_protocol branch October 11, 2023 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants