Skip to content

Commit

Permalink
Merge pull request #153 from pyscal/add_calphy
Browse files Browse the repository at this point in the history
Add calphy
  • Loading branch information
srmnitc authored Jul 23, 2024
2 parents def08c7 + e75501a commit abfe5ce
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.7
current_version = 0.9.8
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ url: 'https://atomrdf.pyscal.org'
license: "MIT"
repository-code: https://github.com/pyscal/atomRDF
type: software
version: 0.9.7
version: 0.9.8
160 changes: 160 additions & 0 deletions atomrdf/workflow/pyiron/calphy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import os
import numpy as np
import ast
from atomrdf.structure import System
import atomrdf.workflow.pyiron.lammps as lammps

def process_job(job):
method_dict = {}
method_dict['intermediate'] = False
lammps.get_structures(job, method_dict)

identify_method(job, method_dict)
extract_calculated_quantities(job, method_dict)
add_software(method_dict)
get_simulation_folder(job, method_dict)
return method_dict

def get_simulation_folder(job, method_dict):
method_dict['path'] = os.path.join(job.project.path, f'{job.name}_hdf5')


def identify_method(job, method_dict):
pressure = job.input.pressure
if pressure is None:
iso = True
fix_lattice = True
elif np.isscalar(pressure):
iso = True
fix_lattice = False
elif np.shape(pressure) == (1,):
iso = True
fix_lattice = False
elif np.shape(pressure) == (2,):
iso = True
fix_lattice = False
elif np.shape(pressure) == (1, 3):
iso = False
fix_lattice = False
elif np.shape(pressure) == (2, 3):
iso = False
fix_lattice = False

dof = []
dof.append("AtomicPositionRelaxation")
ensemble = 'IsothermalIsobaricEnsemble'

if not fix_lattice:
dof.append("CellVolumeRelaxation")
ensemble = "CanonicalEnsemble"

if not iso:
dof.append("CellShapeRelaxation")

method_dict["dof"] = dof
method_dict["ensemble"] = ensemble

#now potential
ps = job.potential.Config.values[0][0].strip().split('pair_style ')[-1]
name = job.potential.Name.values[0]
potstr = job.potential.Citations.values[0]
potdict = ast.literal_eval(potstr[1:-1])
url = None
if "url" in potdict[list(potdict.keys())[0]].keys():
url = potdict[list(potdict.keys())[0]]["url"]

method_dict["potential"] = {}
method_dict["potential"]["type"] = ps
method_dict["potential"]["label"] = name
if url is not None:
method_dict["potential"]["uri"] = url
else:
method_dict["potential"]["uri"] = name
method_dict['method'] = 'ThermodynamicIntegration'
method_dict["temperature"] = job.input.temperature
method_dict["pressure"] = job.input.pressure

def add_software(method_dict):
method_dict["workflow_manager"] = {}
method_dict["workflow_manager"]["uri"] = "http://demo.fiz-karlsruhe.de/matwerk/E457491"
method_dict["workflow_manager"]["label"] = "pyiron"
# and finally code details

software1 = {
"uri": "http://demo.fiz-karlsruhe.de/matwerk/E447986",
"label": "LAMMPS",
}

software2 = {
"uri": "https://doi.org/10.5281/zenodo.10527452",
"label": "Calphy",
}
method_dict["software"] = [software1, software2]

def extract_calculated_quantities(job, method_dict):

outputs = []
outputs.append(
{
"label": "FreeEnergy",
"value": np.round(job['output/energy_free'], decimals=4),
"unit": "EV",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "Pressure",
"value": np.round(job['output/pressure'], decimals=4),
"unit": "GigaPA",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "Temperature",
"value": np.round(job['output/temperature'], decimals=2),
"unit": "K",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "AtomicVolume",
"value": np.round(job['output/atomic_volume'], decimals=4),
"unit": "ANGSTROM3",
"associate_to_sample": True,
}

)

structure = job.get_structure(frame=-1)
lx = np.linalg.norm(structure.cell[0])
ly = np.linalg.norm(structure.cell[1])
lz = np.linalg.norm(structure.cell[2])

outputs.append(
{
"label": "SimulationCellLength_x",
"value": np.round(lx, decimals=4),
"unit": "ANGSTROM",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "SimulationCellLength_y",
"value": np.round(ly, decimals=4),
"unit": "ANGSTROM",
"associate_to_sample": True,
}
)
outputs.append(
{
"label": "SimulationCellLength_z",
"value": np.round(lz, decimals=4),
"unit": "ANGSTROM",
"associate_to_sample": True,
}
)
method_dict['outputs'] = outputs
3 changes: 3 additions & 0 deletions atomrdf/workflow/pyiron/pyiron.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import atomrdf.workflow.pyiron.vasp as vasp
import atomrdf.workflow.pyiron.murnaghan as murnaghan
import atomrdf.workflow.pyiron.quasiharmonic as qha
import atomrdf.workflow.pyiron.calphy as calphy

def process_job(job):
"""
Expand All @@ -35,6 +36,8 @@ def process_job(job):
return murnaghan.process_job(job)
elif type(job).__name__ == 'QuasiHarmonicJob':
return qha.process_job(job)
elif type(job).__name__ == 'Calphy':
return calphy.process_job(job)
else:
raise TypeError("These type of pyiron Job is not currently supported")

Expand Down
5 changes: 5 additions & 0 deletions atomrdf/workflow/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ def _add_method(
elif job_dict["method"] == "QuasiHarmonicModel":
self.kg.add((activity, RDF.type, Namespace("http://purls.helmholtz-metadaten.de/asmo/").QuasiHarmonicModel))

elif job_dict["method"] == "ThermodynamicIntegration":
self._add_dof(job_dict, activity)
self._add_md(job_dict, activity)
self.kg.add((activity, RDF.type, Namespace("http://purls.helmholtz-metadaten.de/asmo/").ThermodynamicIntegration))

# add that structure was generated
self.kg.add((activity, ASMO.hasComputationalMethod, method))
self.kg.add((job_dict['sample']['final'], PROV.wasGeneratedBy, activity))
Expand Down
2 changes: 1 addition & 1 deletion examples/workflow_examples/01_lammps_pyiron.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.1.-1"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='atomrdf',
version='0.9.7',
version='0.9.8',
author='Abril Azocar Guzman, Sarath Menon',
author_email='[email protected]',
description='Ontology based structural manipulation and quering',
Expand Down

0 comments on commit abfe5ce

Please sign in to comment.