Skip to content

Commit

Permalink
Compute lparms0 and pt_lp_factor
Browse files Browse the repository at this point in the history
These can be computed and don't need to be stored.

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Dec 19, 2023
1 parent 6e2e9bd commit 8baa384
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 15 additions & 9 deletions hexrd/material/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def __init__(

self.pressure = 0
self.temperature = 298
self.pt_lp_factor = 1
self.k0 = 100.0
self.k0p = 0.0
self.dk0dt = 0.0
Expand Down Expand Up @@ -478,6 +477,19 @@ def ktp(self, temperature=None):
delT = temperature - 298
return k0p + self.dk0pdt * delT

@property
def pt_lp_factor(self):
return (self.unitcell.vol * 1e3 / self.v0) ** (1 / 3)

@property
def lparms0(self):
# Get the lattice parameters for 0 pressure and temperature (at v0)
lparms = self.lparms
return np.array([
*(lparms[:3] / self.pt_lp_factor),
*lparms[3:],
])

def calc_pressure(self, volume=None, temperature=None):
'''calculate the pressure given the volume
and temperature using the third order
Expand Down Expand Up @@ -537,13 +549,14 @@ def calc_lp_factor(self, pressure=None, temperature=None):
vpt = self.calc_volume(pressure=pressure, temperature=temperature)
return (vpt / vt) ** (1.0 / 3.0)

def calc_lp_at_PT(self, lparms0, pressure=None, temperature=None):
def calc_lp_at_PT(self, pressure=None, temperature=None):
'''calculate the lattice parameters for a given
pressure and temperature using the BM EoS. This
is the main function which will be called from
the GUI.
'''
f = self.calc_lp_factor(pressure=pressure, temperature=temperature)
lparms0 = self.lparms0
return np.array(
[
*(f * lparms0[:3]),
Expand Down Expand Up @@ -794,7 +807,6 @@ def _readCif(self, fcif=DFLT_NAME + '.cif'):
'''
self.pressure = 0
self.temperature = 298
self.pt_lp_factor = 1
self.k0 = 100.0
self.k0p = 0.0
self.dk0dt = 0.0
Expand Down Expand Up @@ -896,11 +908,6 @@ def _readHDFxtal(self, fhdf=DFLT_NAME, xtal=DFLT_NAME):
self.temperature = np.array(gid.get('temperature'),
dtype=np.float64).item()

self.pt_lp_factor = 1
if 'pt_lp_factor' in gid:
self.pt_lp_factor = np.array(gid.get('pt_lp_factor'),
dtype=np.float64).item()

self.k0 = 100.0
if 'k0' in gid:
# this is the isotropic bulk modulus
Expand Down Expand Up @@ -1007,7 +1014,6 @@ def dump_material(self, file, path=None):

AtomInfo['pressure'] = self.pressure
AtomInfo['temperature'] = self.temperature
AtomInfo['pt_lp_factor'] = self.pt_lp_factor

AtomInfo['k0'] = 100.0
if hasattr(self, 'k0'):
Expand Down
3 changes: 0 additions & 3 deletions hexrd/material/mksupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,6 @@ def WriteH5Data(fid, AtomInfo, lat_param, path=None):
did = gid.create_dataset("temperature", (1,), dtype=np.float64)
did.write_direct(np.array(AtomInfo['temperature'], dtype=np.float64))

did = gid.create_dataset("pt_lp_factor", (1,), dtype=np.float64)
did.write_direct(np.array(AtomInfo['pt_lp_factor'], dtype=np.float64))

did = gid.create_dataset("k0", (1,), dtype=np.float64)
did.write_direct(np.array([AtomInfo['k0']], dtype=np.float64))

Expand Down

0 comments on commit 8baa384

Please sign in to comment.