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

Create observables based on Observable_stat and remove state tracking #3723

Merged
merged 9 commits into from
May 25, 2020

Conversation

jngrad
Copy link
Member

@jngrad jngrad commented May 18, 2020

Fixes #2200, partial fix for #3718

Description of changes:

  • removed state tracking from Observable_stat
  • created Observables classes PressureTensor, Pressure, Energy
  • renamed Stress Tensor to Pressure Tensor everywhere

@jngrad jngrad added this to the Espresso 4.2 milestone May 18, 2020
@jngrad jngrad requested a review from fweik May 18, 2020 20:51
@codecov
Copy link

codecov bot commented May 18, 2020

Codecov Report

Merging #3723 into python will decrease coverage by 0%.
The diff coverage is 99%.

Impacted file tree graph

@@          Coverage Diff           @@
##           python   #3723   +/-   ##
======================================
- Coverage      88%     88%   -1%     
======================================
  Files         549     551    +2     
  Lines       24684   24669   -15     
======================================
- Hits        21754   21734   -20     
- Misses       2930    2935    +5     
Impacted Files Coverage Δ
src/core/Observable_stat.cpp 100% <ø> (ø)
src/core/communication.hpp 100% <ø> (ø)
src/core/electrostatics_magnetostatics/coulomb.hpp 100% <ø> (ø)
src/core/electrostatics_magnetostatics/dipole.hpp 84% <ø> (ø)
src/core/electrostatics_magnetostatics/p3m.hpp 100% <ø> (ø)
src/core/grid_based_algorithms/lb.hpp 100% <ø> (ø)
src/core/virtual_sites.cpp 88% <ø> (-1%) ⬇️
src/core/virtual_sites/VirtualSitesRelative.hpp 100% <ø> (ø)
...ript_interface/observables/ParamlessObservable.hpp 100% <ø> (ø)
src/core/pressure.cpp 82% <95%> (+<1%) ⬆️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 87e1f40...699f642. Read the comment docs.

Copy link
Contributor

@fweik fweik left a comment

Choose a reason for hiding this comment

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

LGTM except for minor changes. Maybe @RudolfWeeber can have a look on the interfaces changes, also somebody else needs to sign off on the stress tensor name change ;-)

src/core/Observable_stat.cpp Outdated Show resolved Hide resolved
src/core/Observable_stat.cpp Outdated Show resolved Hide resolved
src/core/pressure_inline.hpp Show resolved Hide resolved
fweik
fweik previously approved these changes May 19, 2020
@jngrad
Copy link
Member Author

jngrad commented May 19, 2020

@RudolfWeeber would you like to have a look? The API change is limited to renaming the StessTensor observable to PressureTensor. Methods in system.analysis did not change name and return the same dict objects as before.

@RudolfWeeber
Copy link
Contributor

RudolfWeeber commented May 19, 2020 via email

@RudolfWeeber
Copy link
Contributor

If we use "pressure tensor"now, that name should be used also in the espressomd.analysis module. Otherwise, it'd be a bit confusing.

Where does the energy of the Homogeneous magnetic field go? If I understand the Pr correctly, this is no longer separable from the dipole-dipole energy? That's probably not ideal.

@jngrad
Copy link
Member Author

jngrad commented May 20, 2020

Where does the energy of the Homogeneous magnetic field go? If I understand the Pr correctly, this is no longer separable from the dipole-dipole energy? That's probably not ideal.

Indeed, this PR merges all dipolar contributions into a single field. Electrostatic and magnetostatic methods were storing their various contributions into unlabeled slots, which only works if contributors know exactly what they are doing when they write obs_energy.local.dipolar[0] += energy;. The python interface used to give the different contributions with the integer index of the field, which can only be interpreted by those familiar with the C++ code.

Looking again at the diff, it seems the dipolar energies are written to the fields following a pattern, e.g. magnetic field-dipole and dipole-dipole interactions in [0], dipolar solver in [1], corrections in [2]. If we revert back to the old behavior, we should at least document this somewhere, as it wasn't obvious to me.

If we use "pressure tensor"now, that name should be used also in the espressomd.analysis module. Otherwise, it'd be a bit confusing.

I would prefer not to modify this part of the espressomd.analysis module as it would break everyone's scripts. The long-term plan is to replace this module with observables anyway, so there's no need for developers and users to spend effort in adapting code and scripts to the new convention in analysis, only to have to spend time again adapting scripts to observables once we remove the feature from the analysis module.

At the moment, the PressureTensor/Pressure/Energy observable framework is still work in progress. What about the following: once we're done with the observables infrastructure, we'll let ICP members know they should consider updating their scripts to use observables while the analysis module remains for a grace period, as we did for steepest descent (that grace period would end before the release deadline). For as long as the observables framework remains a WIP, I'd be fine with naming PressureTensor back to StressTensor.

@RudolfWeeber
Copy link
Contributor

RudolfWeeber commented May 20, 2020 via email

jngrad added 7 commits May 21, 2020 15:05
Recalculate energy, scalar pressure and pressure tensor whenever
the corresponding python analysis module functions are called.
Return only the total pressure tensor, scalar pressure, energy.
Rename StressTensor to PressureTensor since it has the sign of a
pressure.
Fixes -Wnonportable-include-path on AppleClang 9 (non-portable path
to file '"Energy.hpp"'; specified path differs in case from file
name on disk: #include "energy.hpp").
Avoids a side effect when the first test class fails, leaving the
system in an unclean state for the next test class.
@jngrad
Copy link
Member Author

jngrad commented May 21, 2020

So, I vote for renaming to pressure tensor everywhere.

Done everywhere in c5a19f4. I've also made the change in exported functions of the LB code. There were a few comments in the LB code and LB tutorials to remind developers that LB stress was in fact LB pressure.

I’d keep the individual ones, but as you suggest, change the key names in the return dict of analsys.energy()

I've removed the commits that merged dipole slots into a single field. Same for electrostatics. These slots are now documented in 072180f.

The rest of the commits have been slightly touched to resolve conflicts from the removal.

@fweik fweik self-assigned this May 25, 2020
@fweik
Copy link
Contributor

fweik commented May 25, 2020

@RudolfWeeber can you please check if your points have been addressed?

@fweik fweik added the automerge Merge with kodiak label May 25, 2020
@fweik
Copy link
Contributor

fweik commented May 25, 2020

For what its worth, I think it is a mistake to keep the separate long-rang and short-range contributions from the dipolar and electrstatics solvers exposed. Using them separately is almost always a mistake,
we should not encourage depending on details of solvers.

@kodiakhq kodiakhq bot merged commit 17ce4ee into espressomd:python May 25, 2020
@jngrad jngrad deleted the obsstat-observable branch January 18, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stress tensor should be renamed to pressure tensor
3 participants