-
Notifications
You must be signed in to change notification settings - Fork 708
LinearDensity should have more reliable tests #3603
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
Comments
Thanks for this issue. If somebody wants to start on this. The following lines can be used to generate a Universe of individual atoms. import MDAnalysis as mda
import numpy as np
from MDAnalysis.core._get_readers import get_reader_for
def make_Universe():
"""Generate a reference universe of 100 atoms with uniformly drawn random positions."""
n_atoms = 100
n_frames = 100
u = mda.Universe.empty(n_atoms=n_atoms,
n_residues=n_atoms,
n_segments=n_atoms,
atom_resindex=np.arange(n_atoms),
residue_segindex=np.arange(n_atoms))
for attr in ["charges", "masses"]:
u.add_TopologyAttr(attr, values=np.ones(n_atoms))
shape = (n_frames, n_atoms, 3)
coords = np.random.random(shape)
u.trajectory = get_reader_for(coords)(coords,
order='fac',
n_atoms=n_atoms)
for ts in u.trajectory:
ts.dimensions = np.array([1, 1, 1, 90, 90, 90])
return u |
i want to start on this |
@olivia632 cool! I suggest that you calculate the density using the make_universe function and compare it to the values you would calculate based on the system parameters. The number of particles is 100, the volume is 1 Å^3, the mass per particle is 1 u and the charge is 1 e. If I am not mistaken the mass density in each bin and direction should be 100 u/Å^3 and the charge 100 e/Å^3. |
k I will work on that and then reach you back |
You can also reach me on discord if you have any general questions. |
there are 3 test cases failing in the original code can you clarify on that |
==================================== short test summary info ==================================== |
@olivia632 did you figures out what is going wrong (Pull the to latest version from github etc?). The tests seem to work for the CI... |
Hello, my name is Echo (they/them), and I'm interested in having a look at this issue as part of my GSoC 2025 application (Project 5)! My understanding of the problem:
Aim:
Developing a solution:
Questions:
...wow, that was a lot of words, sorry. My wifi has unfortunately crashed for like a week which is a little awkward, but I'll hopefully be able to finish this before the GSoC 2025 deadline, but I'd like to keep working on it afterwards even if not. I'm also quite new to Git, and so will be asking a friend to help with how to work a Pull Request, and would appreciate any advice on how to structure comments and such as well (as this has gotten very long...). But yeah, looking forward to working on this! |
…e feedback as this is just a rough attempt
Is your feature request related to a problem?
Currently, some of the tests in test_lineardensity.py are basically tautologies because the expected values the tests check against were obtained by running lineardensity.py. This is the case for the following expected values:
expected_xchar_atoms
expected_xpos_residues
expected_xchar_residues
expected_xpos_segments
expected_xchar_segments
expected_xpos_fragments
expected_xchar_fragments
The current test Universe
u = mda.Universe(waterPSF, waterDCD)
is not ideal for determining charge densities by residues, segments, or fragments, because in these groupings the overall charge is zero.Describe the solution you'd like
The expected values should be obtained independently from LinearDensity so that the tests are actually meaningful.
@PicoCentauri had the following suggestion for how this might be achieved:
Describe alternatives you've considered
Currently,
expected_xpos_atoms
came from a different source. One could look into how these values were originally determined and replicate this for the other test cases.Additional context
This came up in a discussion on PR #3572
The text was updated successfully, but these errors were encountered: