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

Set target temperature through a common code path #513

Merged
merged 21 commits into from
Jan 31, 2023
Merged

Conversation

giacomofiorin
Copy link
Member

@giacomofiorin giacomofiorin commented Jan 25, 2023

Minimize divergences between MD engines by storing the target temperature in a proxy member and provide a shared function set_target_temperature() to set it. The previous virtual function temperature() is now a const accessor target_temperature().

Additionally, there is now a script method settemperature targettemperature to set it in scripts, i.e. in post-processing or when we are temporarily unable to get it from the MD engine (see e.g. #218).

Questions:

  • Should set_target_temperature() be virtual or just remain a plain setter?
  • Name of the script function (settemperature -> settargettemperature`)?

@jhenin
Copy link
Member

jhenin commented Jan 25, 2023

Should set_target_temperature() be virtual or just remain a plain setter?

Trying to think of a possible use for an override... The only one that comes to mind is an annealing method that would be driven from Colvars. That seems distant and unlikely, so I'd keep a plain setter for now, for simplicity. If the need arises to override it, making it virtual will be an easy change.

Name of the script function (settemperature -> settargettemperature)?

I think a getter would be useful too. The function could be called targettemperature and be a getter/setter like cv frame.

@giacomofiorin giacomofiorin marked this pull request as ready for review January 25, 2023 17:55
Copy link
Member

@HubLot HubLot left a comment

Choose a reason for hiding this comment

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

I just have 2 comments but otherwise it's looks good on the gromacs side

// From Gnu units
// $ units -ts 'k' 'kJ/mol/K/avogadro'
// 0.0083144621
boltzmann_ = 0.0083144621;
Copy link
Member

Choose a reason for hiding this comment

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

It could be worth using the GROMACS constant here: see gmx::c_boltz

Copy link
Member

Choose a reason for hiding this comment

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

I know we always write the number before but we could benefit from the PR

Copy link
Member Author

Choose a reason for hiding this comment

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

@HubLot I couldn't the definition of c_boltz anywhere. Is it auto-generated? I tried guessing from what similar source files include.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried but...
image

Copy link
Member

Choose a reason for hiding this comment

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

okay so:

  • for 2020 & 2021: #include "gromacs/math/units.h" with BOLTZ as a name (without gmx::)
  • for 2022: #include "gromacs/math/units.h" with gmx::c_boltz

Copy link
Member

Choose a reason for hiding this comment

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

didn't catch they changed the constant name in 2022 and above :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay this works. Thanks!

@jhenin
Copy link
Member

jhenin commented Jan 27, 2023

Trying VMD...

vmd > cv targettemperature
9.04115e+271

Hmmm... This will need a little fix.

and remove now unused backend_angstrom_value()
and kcal_mol_value, which is unused but preserved for completeness
@jhenin
Copy link
Member

jhenin commented Jan 27, 2023

Force-pushed an update because of malicious behavior of multi-file search in VS Code, intentionally missing Gromacs files.

@@ -2107,18 +2107,6 @@ int cvm::load_coords_xyz(char const *filename,
// Wrappers to proxy functions: these may go in the future
Copy link
Member

Choose a reason for hiding this comment

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

"these may go in the future": Is this the right time to get rid of the other wrapper functions below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely, but in another PR. #487 is an example where tidying things up ended up in the way of finishing a specific task.

@giacomofiorin
Copy link
Member Author

Hmmm... This will need a little fix.

...or not. Remember that in VMD it is the caller's responsibility to initialize class members? :-)

@jhenin
Copy link
Member

jhenin commented Jan 27, 2023

Remember that in VMD it is the caller's responsibility to initialize class members? :-)

@jhenin jhenin closed this Jan 27, 2023
@jhenin jhenin reopened this Jan 27, 2023
@jhenin jhenin merged commit df9fb2e into master Jan 31, 2023
@giacomofiorin giacomofiorin deleted the update_temperature branch May 1, 2023 15:04
giacomofiorin added a commit to Colvars/lammps that referenced this pull request May 17, 2023
This update consists exclusively of bugfixes or maintenance-related changes.

The following is a list of pull requests in the Colvars repository since the previous update to LAMMPS:

- 532 Add XYZ trajectory reading feature
  Colvars/colvars#532 (@jhenin, @giacomofiorin)

- 531 Delete objects quietly, unless explicitly requested via script (including VMD)
  Colvars/colvars#531 (@giacomofiorin)

- 530 Append newline to log and error messages if not already present
  Colvars/colvars#530 (@giacomofiorin)

- 528 Forward-declare OpenMP lock
  Colvars/colvars#528 (@giacomofiorin)

- 527 Remove unneeded STL container
  Colvars/colvars#527 (@giacomofiorin)

- 526 Allow collecting configuration files and strings before setting up interface
  Colvars/colvars#526 (@giacomofiorin, @jhenin)

- 523 Fallback to linearCombination when customFunction is missing in customColvar
  Colvars/colvars#523 (@HanatoK, @giacomofiorin)

- 522 Use iostream::fail() to check for I/O error
  Colvars/colvars#522 (@jhenin)

- 520 Fix ref count
  Colvars/colvars#520 (@giacomofiorin)

- 513 Set target temperature through a common code path
  Colvars/colvars#513 (@giacomofiorin, @jhenin)

- 509 Safer detection of Windows with recent Microsoft Visual Studio versions
  Colvars/colvars#509 (@akohlmey)

- 508 Update LAMMPS patching method to reflect Lepton availability
  Colvars/colvars#508 (@giacomofiorin)

- 497 Increase the precision of write_multicol
  Colvars/colvars#497 (@HanatoK)

- 496 Only perform MTS automatic enable/disable for timeStepFactor > 1
  Colvars/colvars#496 (@giacomofiorin)

- 493 Remove unused branch of quaternion input function
  Colvars/colvars#493 (@giacomofiorin)

- 489 Ensure there are spaces between the fields in the header
  Colvars/colvars#489 (@HanatoK)

- 487 Use map of output streams, and return references to its elements
  Colvars/colvars#487 (@giacomofiorin, @jhenin)

- 486 Remember first step of moving restraint
  Colvars/colvars#486 (@jhenin)

- 485 Add decoupling option for moving restraints
  Colvars/colvars#485 (@jhenin)

- 483 Update Lepton via patching procedure
  Colvars/colvars#483 (@giacomofiorin)

- 481 Make file-reading operations of input data abstractable
  Colvars/colvars#481 (@giacomofiorin)

Authors: @akohlmey, @giacomofiorin, @HanatoK, @jhenin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants