Skip to content

Conversation

@harveydevereux
Copy link
Collaborator

@harveydevereux harveydevereux commented Oct 14, 2025

Draft additions to implement the elasticity calculations for issue #620.

Notebook tutorials have a three-way comparison between Aluminium, Diamond, and a Carbon-nanotube

ecs

At the moment the core output is the pymatgen ElasticityTensor which houses properties and methods relating to the data.

Written output is for now the derived data and the whole tensor.

$ cat elasticity-elastic_tensor.dat 
# Bulk modulus (Reuss) [GPa] | Bulk modulus (Voigt) [GPa] | Bulk modulus (VRH) [GPa] | Shear modulus (Reuss) [GPa] | Shear modulus (Voigt) [GPa] | Shear modulus (VRH) [GPa] | Young's modulus [GPa] | Universal anisotropy | Homogeneous Poisson ratio | Elastic constants (row-major) [GPa]
80.34637735135314 80.34637735135317 80.34637735135315 22.54802608157279 23.344621055880044 22.946323568726417 62855302809.64485 0.17664405997788535 0.36961597838074717 104.69105725174975 0.0 0.0 0.0 68.1740374011551 0.0 0.0 0.0 68.17403740115496 0.0 26.7353618096018 0.0 26.7353618096018 0.0 0.0 0.0 0.0 0.0 0.0 0.0 26.735361809601777 0.0 0.0 0.0 26.735361809601777 0.0 0.0 0.0 26.7353618096018 0.0 26.7353618096018 0.0 0.0 0.0 0.0 0.0 68.17403740115469 0.0 0.0 0.0 104.69105725174938 0.0 0.0 0.0 68.1740374011544 0.0 0.0 0.0 0.0 0.0 26.73536180960179 0.0 26.73536180960179 0.0 0.0 0.0 26.735361809601777 0.0 0.0 0.0 26.735361809601777 0.0 0.0 0.0 0.0 0.0 0.0 0.0 26.73536180960179 0.0 26.73536180960179 0.0 68.17403740115525 0.0 0.0 0.0 68.17403740115505 0.0 0.0 0.0 104.69105725174995

However the 6x6 Voigt form would be nice (with names), by the looks Tensor.get_voigt_dict might gives those indices, and there are some helpers for the naming conventions too. But maybe someone does want the whole thing.

Feature TODO

  • optional (but default) Voigt notation written output (6x6)
  • CLI implementation
  • Options for DeformedStructureSet etc.
  • Documentation
  • Example/Notebook?

Testing TODO

  • Test written output
  • Test optimization options and their outputs
  • Test CLI

@harveydevereux harveydevereux self-assigned this Oct 14, 2025
@ElliottKasoar ElliottKasoar added the enhancement New/improved feature or request label Nov 6, 2025
@harveydevereux harveydevereux marked this pull request as ready for review November 12, 2025 11:03
@alinelena
Copy link
Member

one thing I think would be nice to have... dump all the structures used in calculation since they can be a good source of data for training

@harveydevereux
Copy link
Collaborator Author

harveydevereux commented Nov 17, 2025

one thing I think would be nice to have... dump all the structures used in calculation since they can be a good source of data for training

I.e. also the non-optimised strained structures?

Currently you can dump:

  • The initial geometry optimised structure.
  • The strained structures (but not the pre-optimised ones).
    @alinelena Actually this is already implemented. Although if you optimise all, then it will only write out optimised strained structures.

@alinelena
Copy link
Member

  • The strained structures (but not the pre-optimised ones).
    @alinelena Actually this is already implemented. Although if you optimise all, then it will only write out optimised strained structures.

can we have the initial ones too?

Copy link
Member

@ElliottKasoar ElliottKasoar left a comment

Choose a reason for hiding this comment

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

This looks great, thank you @harveydevereux!

Can you add links to the tutorials with Colab links to the README/relevant user guide pages please?

I'm not sure writing the structures out works exactly as expected. If I run one of your example CLI commands:

janus elasticity --struct tests/data/NaCl.cif --arch mace_mp --shear-magnitude 0.1 --normal-magnitude 0.02 --n-strains 10 --write-structures

This writes either 60 or 61. structures, depending on whether we optimise nothing, or the (initial) structure(s).

I think I'd expect the number of structures in this file to be independent of the choice of optimisation?

It also seems to append the same file if I rerun the command, which I don't think is expected.

Copy link
Member

Choose a reason for hiding this comment

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

I get

/Users/elliottkasoar/Documents/PSDI/janus-core/docs/source/apidoc/janus_core.rst:48: WARNING: py:class reference target not found: ElasticTensor [ref.class]

Can you try updating the intersphinx mapping to include pymatgen, and if that doesn't work, add this to the ignore list?

"outputs": [],
"source": [
"from janus_core import __version__\n",
"()\n",
Copy link
Member

Choose a reason for hiding this comment

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

Typo?

Copy link
Member

Choose a reason for hiding this comment

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

It might be nice either in this or the Python tutorial to visualise all the structures we generate? Weas can read a "trajectory" e.g. our generated structures.

Or does it not look very interesting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Might as well for the tutorial, I've not looked how visual it is. Will check

@harveydevereux
Copy link
Collaborator Author

This looks great, thank you @harveydevereux!

Can you add links to the tutorials with Colab links to the README/relevant user guide pages please?

I'm not sure writing the structures out works exactly as expected. If I run one of your example CLI commands:

janus elasticity --struct tests/data/NaCl.cif --arch mace_mp --shear-magnitude 0.1 --normal-magnitude 0.02 --n-strains 10 --write-structures

This writes either 60 or 61. structures, depending on whether we optimise nothing, or the (initial) structure(s).

I think I'd expect the number of structures in this file to be independent of the choice of optimisation?

It also seems to append the same file if I rerun the command, which I don't think is expected.

In this case its the initial structure --struct XXX that does not get written, unless optimised. It can be copied in if we save it/its path or write it before opt.

I was thinking though if it is also useful to split the optimised, and pre-optimised outputs into two separate files? Or does optimisation push some meta data to a structure to tag them in one file? Perhaps also the strain can be put in meta data (if its not already somehow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New/improved feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants