Skip to content

Commit

Permalink
Merge pull request #95 from pyiron/abstract_test
Browse files Browse the repository at this point in the history
Add test for abstract workflow class
  • Loading branch information
jan-janssen authored Nov 29, 2023
2 parents 70aebfb + 77e7fb4 commit b6bdb2f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_abstract_workflow_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest

from atomistics.workflows.shared.workflow import Workflow


class WorkflowClass(Workflow):
pass


class TestWorkflowClass(unittest.TestCase):
def test_generate_structures(self):
with self.assertRaises(NotImplementedError):
temp = WorkflowClass()
temp.generate_structures()

def test_analyse_structures(self):
with self.assertRaises(NotImplementedError):
temp = WorkflowClass()
temp.analyse_structures(output_dict={})
65 changes: 65 additions & 0 deletions tests/test_evcurve_eos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import numpy as np

import unittest

from atomistics.workflows.evcurve.fit import fit_equation_of_state


class TestEvCurve(unittest.TestCase):
def setUp(self):
self.volumes = [
63.10883669478296,
63.77314023893856,
64.43744378309412,
65.10174732724975,
65.7660508714054,
66.43035441556098,
67.09465795971657,
67.7589615038722,
68.42326504802779,
69.08756859218344,
69.75187213633905
]
self.energies = [
-13.39817505470619,
-13.4133940159381,
-13.425115937672247,
-13.433413658516752,
-13.438358754759532,
-13.439999952735112,
-13.438382355644501,
-13.433605756604651,
-13.42577121684493,
-13.41495739484744,
-13.401227593921211
]

def test_birch(self):
fit_dict = fit_equation_of_state(volume_lst=self.volumes, energy_lst=self.energies, fittype='birch')
self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.43019853103964))
self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 77.7433780646763))
self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 1.2836228593874182))

def test_birchmurnaghan(self):
fit_dict = fit_equation_of_state(volume_lst=self.volumes, energy_lst=self.energies, fittype='birchmurnaghan')
self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.43019853103964))
self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 77.74337806467966))
self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 1.2836228593684815))

def test_murnaghan(self):
fit_dict = fit_equation_of_state(volume_lst=self.volumes, energy_lst=self.energies, fittype='murnaghan')
self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.43019853103964))
self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 77.60443933015738))
self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 1.2716548170090776))

def test_pouriertarantola(self):
fit_dict = fit_equation_of_state(volume_lst=self.volumes, energy_lst=self.energies, fittype='pouriertarantola')
self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.43019853103964))
self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 77.61743376692809))
self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 1.272111993713677))

def test_vinet(self):
fit_dict = fit_equation_of_state(volume_lst=self.volumes, energy_lst=self.energies, fittype='vinet')
self.assertTrue(np.isclose(fit_dict['volume_eq'], 66.43019853103964))
self.assertTrue(np.isclose(fit_dict['bulkmodul_eq'], 77.61265363975706))
self.assertTrue(np.isclose(fit_dict['b_prime_eq'], 1.2734991618131122))

0 comments on commit b6bdb2f

Please sign in to comment.