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

Elastic tensor and child jobs when submitting #197

Closed
Leimeroth opened this issue May 16, 2021 · 13 comments
Closed

Elastic tensor and child jobs when submitting #197

Leimeroth opened this issue May 16, 2021 · 13 comments
Labels
bug Something isn't working question Further information is requested

Comments

@Leimeroth
Copy link
Member

Leimeroth commented May 16, 2021

Also see updates 1 and 2 below, issues seems to be the storage of pressure in vasp jobs
Summary

ElasticTensor jobs fail for me when I submit them to our remote cluster.
I am not really sure but I think this could be related to some other weird behavior which I noticed that affects all AtomisticParallel jobs. When I submitted Murnaghan jobs with old pyiron versions (not sure which ones) each child job was given an id and stored in the local database, then each job was submitted to the cluster. Now only the master job is stored in the local database and submitted to the cluster. This has the side effect that the child_ids attribute is an empty list, maybe this causes the issue?
Murnaghan jobs still work, even if there child_ids is empty, so maybe something else causes the problem.

pyiron Version and Platform

Newest pyiron versions from git.

Steps to Reproduce

Submit a ElasticTensor job to a remote cluster.

Error message

  File "/home/nl77pupy/miniconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/nl77pupy/miniconda3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/cli/__main__.py", line 2, in <module>
    main()
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/cli/__init__.py", line 61, in main
    args.cli(args)
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/cli/wrapper.py", line 34, in main
    job_wrapper_function(
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/job/wrapper.py", line 149, in job_wrapper_function
    job.run()
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/job/wrapper.py", line 115, in run
    self.job.run_static()
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/master/parallel.py", line 678, in run_static
    self._run_if_master_modal_child_non_modal(job=job)
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/master/parallel.py", line 657, in _run_if_master_modal_child_non_modal
    self.run()  # self.run_if_collect()
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/generic/util.py", line 213, in decorated
    return function(*args, **kwargs)
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/job/generic.py", line 670, in run
    self._run_if_collect()
  File "/home/nl77pupy/git_projects/pyiron_base/pyiron_base/master/parallel.py", line 488, in _run_if_collect
    self.collect_output()
  File "/home/nl77pupy/git_projects/pyiron_atomistics/pyiron_atomistics/atomistics/master/elastic.py", line 525, in collect_output
    elastic_tensor, score = calc_elastic_tensor(
  File "/home/nl77pupy/git_projects/pyiron_atomistics/pyiron_atomistics/atomistics/master/elastic.py", line 274, in calc_elastic_tensor
    coeff, score = _fit_coeffs_with_stress(
  File "/home/nl77pupy/git_projects/pyiron_atomistics/pyiron_atomistics/atomistics/master/elastic.py", line 106, in _fit_coeffs_with_stress
    stress = _convert_to_voigt(stress, rotations=rotations, strain=False)
  File "/home/nl77pupy/git_projects/pyiron_atomistics/pyiron_atomistics/atomistics/master/elastic.py", line 79, in _convert_to_voigt
    s_tmp = np.einsum('nik,mkl,njl->nmij',
  File "<__array_function__ internals>", line 5, in einsum
  File "/home/nl77pupy/miniconda3/lib/python3.8/site-packages/numpy/core/einsumfunc.py", line 1361, in einsum
    return c_einsum(*operands, **kwargs)
ValueError: einstein sum subscripts string contains too many subscripts for operand 1
@Leimeroth Leimeroth added the bug Something isn't working label May 16, 2021
@Leimeroth
Copy link
Member Author

Update
For lammps jobs it seems to work, the child_ids list is still empty but it calculates the elastic tensor.
Maybe the ElasticTensor class doesn't work with vasp? It would be nice if someone with a local vasp installation could test that.

@Leimeroth Leimeroth added the question Further information is requested label May 17, 2021
@Leimeroth
Copy link
Member Author

I was able to confirm that this also occurs with a local vasp installation and I think the issue is that the pressure stored in vasp jobs is a scalar, while it is a 3x3 matrix for lammps. I think it would be good to catch this somewhere in the ElasticTensor class.

Also it is a bit unclear to me if it is possible to purposely switch to calculation of elastic constants based on energy instead of stresses, since accurate stresses require very high energy cutoffs in dft calculations? The _fit_coeffs_with_energies already exists, but it only seems to get triggered if no pressures are calculated. It would be great if that would be a user option imo.
Would be great if you could have look at this @samwaseda

@samwaseda
Copy link
Member

I'm going to make sure that there's an option to make energy fitting available even if there's a pressure entry. Other than that I don't really understand why there's only one pressure value and not a pressure tensor. I guess that's something @sudarsan-surendralal can correct?

@sudarsan-surendralal
Copy link
Member

sudarsan-surendralal commented May 26, 2021

I'm not super familiar with the definition of VASP pressures and I am not 100% sure that the stresses output from VASP directly compares to the (3x3) pressure output from LAMMPS. A typical VASP stresses output looks like this

FORCE on cell =-STRESS in cart. coord.  units (eV):
  Direction    XX          YY          ZZ          XY          YZ          ZX
  --------------------------------------------------------------------------------------
  Alpha Z   122.02745   122.02745   122.02745
  Ewald    -399.26997  -399.26997  -399.26997     0.00000    -0.00000    -0.00000
  Hartree    61.29482    61.29482    61.29482    -0.00000    -0.00000    -0.00000
  E(xc)     -79.08676   -79.08676   -79.08676    -0.00000     0.00000     0.00000
  Local     119.45678   119.45677   119.45678    -0.00000     0.00000     0.00000
  n-local   -54.79865   -53.13826   -51.47787     0.53348     0.13342     0.51818
  augment    76.60245    76.60245    76.60245     0.00000     0.00000     0.00000
  Kinetic   150.16150   148.80689   147.45227     0.32626    -0.35441     0.70879
  Fock        0.00000     0.00000     0.00000     0.00000     0.00000     0.00000
  -------------------------------------------------------------------------------------
  Total      -3.30660    -3.30660    -3.30660     0.00000    -0.00000     0.00000
  in kB    -241.33405  -241.33409  -241.33405     0.00000    -0.00000     0.00000
  external pressure =     -241.33 kB  Pullay stress =        0.00 kB

We currently parse the second last line (which gives the stress tensor) and average over the diagonal components of the stress tensor to calculate the hydrostatic pressure which is a scalar.

np.average(stresses[:, 0:3], axis=1) * KBAR_TO_EVA

@samwaseda @Leimeroth , does this correspond to the "pressure tensor" defined in LAMMPS (https://lammps.sandia.gov/doc/compute_pressure.html#description)

@samwaseda
Copy link
Member

samwaseda commented May 26, 2021

I presume that the values given in Total are the direct results of the Virial theorem, meaning they are pressure times volume. Probably the pressures are Total divided by volume.

But it might make sense to check whether pressure * epsilon * volume gives energy

@sudarsan-surendralal
Copy link
Member

But it might make sense to check whether pressure * epsilon * volume gives energy

What does epsilon stand for here?

@samwaseda
Copy link
Member

But it might make sense to check whether pressure * epsilon * volume gives energy

What does epsilon stand for here?

Sorry strain. And it should be stress and not pressure (stress = -pressure)

@jan-janssen
Copy link
Member

@Leimeroth Is this issue fixed?

@Leimeroth
Copy link
Member Author

I don't know if all issues that came up here are fixed. Master jobs and using the energy to fit elastic constants work now, but I am not sure how pressure is stored in VASP jobs now.

@pmrv
Copy link
Contributor

pmrv commented Dec 14, 2021

As of #354 the voigt stresses are in the HDF files under output/generic/stresses. This is different from the lammps jobs where they are under output/generic/pressures, so I'm not sure if this requires special casing in the elastic job.

@samwaseda
Copy link
Member

As of #354 the voigt stresses are in the HDF files under output/generic/stresses. This is different from the lammps jobs where they are under output/generic/pressures, so I'm not sure if this requires special casing in the elastic job.

Yeah I'd say that's a problem. Is there a particular reason that it shouldn't be available in output/generic/pressures?

@pmrv
Copy link
Contributor

pmrv commented Jun 20, 2022

See this. For some reason that was already taken and back then we decided not to change the meaning because of backwards compat.

@Leimeroth
Copy link
Member Author

I think this is fixed since vasp stores the tensor now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants