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

FIX: Thermodynamics when loading databases without mobility parameters #12

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/01_Binary_Precipitation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"\tbeta\t0.000e+00\t\t0.0000\t\t0.0000e+00\t5.7737e+03\n",
"\n",
"N\tTime (s)\tSim Time (s)\tTemperature (K)\tMatrix Comp\n",
"3675\t1.8e+06\t\t20.0\t\t723\t\t0.0126\n",
"3675\t1.8e+06\t\t12.0\t\t723\t\t0.0126\n",
"\n",
"\tPhase\tPrec Density (#/m3)\tVolume Frac\tAvg Radius (m)\tDriving Force (J/mol)\n",
"\tbeta\t1.374e+22\t\t1.5504\t\t6.1126e-09\t3.2902e+02\n",
Expand Down
12 changes: 6 additions & 6 deletions examples/02_Multicomponent_Precipitation.ipynb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions examples/06_Single_Phase_Diffusion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@
"text": [
"Iteration\tSim Time (h)\tRun time (s)\n",
"0\t\t0.0e+00\t\t0.0\n",
"100\t\t2.9e+01\t\t3.2\n",
"200\t\t5.7e+01\t\t6.4\n",
"300\t\t8.6e+01\t\t8.7\n",
"349\t\t1.0e+02\t\t9.3\n"
"100\t\t2.9e+01\t\t2.5\n",
"200\t\t5.7e+01\t\t5.2\n",
"300\t\t8.6e+01\t\t7.0\n",
"349\t\t1.0e+02\t\t7.5\n"
]
}
],
Expand Down
8 changes: 4 additions & 4 deletions examples/09_Thermodynamics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x14345dd6a60>"
"<matplotlib.legend.Legend at 0x13a9d934ca0>"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -226,7 +226,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x1434b483c40>"
"<matplotlib.legend.Legend at 0x13aa2016700>"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -312,7 +312,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x1434c889cd0>"
"<matplotlib.legend.Legend at 0x13aa4399d60>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -403,7 +403,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x1434c93c340>"
"<matplotlib.legend.Legend at 0x13aa45ad310>"
]
},
"execution_count": 8,
Expand Down
56 changes: 56 additions & 0 deletions kawin/tests/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,62 @@
PARAMETER DQ(FCC_A1&ZR,*:VA;0) 298.15 -242000; 6000 N !
"""

ALZR_TDB_NO_MOB = """
$Al-Zr database without any mobility parameters
$From T. Wang, Z. Jin, J. Zhao, Journal of Phase Equilibria, 22 (2001) p. 544
$
TEMP_LIM 298.15 6000 !
$Element Standard state mass [g/mol] H_298 S_298
ELEMENT /- ELECTRON_GAS 0.0 0.0 0.0 !
ELEMENT VA VACUUM 0.0000E+00 0.0000E+00 0.0000E+00 !
ELEMENT AL FCC_A1 2.6982E+01 4.5773E+03 2.8322E+01 !
ELEMENT ZR HCP_A3 9.1224E+01 5.5663E+03 3.9181E+01 !
$
$
TYPE_DEFINITION % SEQ *!
$
$PHASE AL3ZR
PHASE AL3ZR % 2 0.75 0.25 !
CONST AL3ZR : AL : ZR : !
$
$PHASE FCC_A1
PHASE FCC_A1 % 2 1 1 !
CONST FCC_A1 : AL%,ZR : VA : !
$
$
$
$
$UNARY DATA
$
$AL (FCC_A1)
FUNCTION GHSERAL 298.15 -7976.15+137.093038*T-24.3671976*T*LOG(T)
-1.884662E-3*T**2-0.877664E-6*T**3+74092*T**(-1);
700.00 Y -11276.24+223.048446*T-38.5844296*T*LOG(T)
+18.531982E-3*T**2-5.764227E-6*T**3+74092*T**(-1);
933.47 Y -11278.378+188.684153*T-31.748192*T*LOG(T)
-1230.524E25*T**(-9); 2900.00 N !
$
$ ZIRCONIUM (GHSERZR FOR HCP_A3)
$
FUNCTION GHSERZR 130.00 -7827.595+125.64905*T-24.1618*T*LOG(T)
-4.37791E-3*T**2+34971*T**(-1);
2128.00 Y -26085.921+262.724183*T-42.144*T*LOG(T)
-1342.895E28*T**(-9); 6000.00 N !

$
$ PHASE FCC_A1
$
PARAMETER G(FCC_A1,AL:VA;0) 298.15 GHSERAL; 6000.00 N !
PARAMETER G(FCC_A1,ZR:VA;0) 298.15 7600.00-0.9*T+GHSERZR; 6000.00 N !
PARAMETER G(FCC_A1,AL,ZR:VA;0) 298.15 -152947+21.3*T; 6000.00 N !

$
$ PHASE AL3ZR
$
PARAMETER G(AL3ZR,AL:ZR;0) 298.15 -47381 - 24.373*T + 3.894*T*LOG(T)
+0.75*GHSERAL+0.25*GHSERZR; 6000.00 N !
"""

NICRAL_TDB = """

$ The parameters of the following database follows the publication
Expand Down
3 changes: 3 additions & 0 deletions kawin/tests/test_thermodynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
AlCrNiTherm.setDFSamplingDensity(2000)
AlCrNiTherm.setEQSamplingDensity(500)

def test_load_database_without_mobility():
therm_nomob = BinaryThermodynamics(ALZR_TDB_NO_MOB, ['AL', 'ZR'], ['FCC_A1', 'AL3ZR'])

def test_DG_binary():
'''
Checks value of binary driving force calculation
Expand Down
14 changes: 8 additions & 6 deletions kawin/thermo/Thermodynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class GeneralThermodynamics:
'''

gOffset = 1 #Small value to add to precipitate phase for when order/disorder models are used
stateVariables = sorted([v.GE, v.N, v.P, v.T], key=str)

def __init__(self, database, elements, phases, drivingForceMethod = 'tangent', parameters = None):
if isinstance(database, str):
Expand Down Expand Up @@ -129,11 +130,11 @@ def _buildThermoModels(self):
#This may be unnecessary as already disordered phase models will not be affected, but I guess just in case the matrix phase happens to be an ordered solution
param_keys, _ = extract_parameters(self._parameters)
self.models = {self.phases[0]: Model(self.db, self.elements, self.phases[0], parameters=param_keys)}
self.models[self.phases[0]].state_variables = sorted([v.T, v.P, v.N, v.GE], key=str)
self.models[self.phases[0]].state_variables = self.stateVariables

for i in range(1, len(self.phases)):
self.models[self.phases[i]] = ExtraGibbsModel(self.db, self.elements, self.phases[i], parameters=param_keys)
self.models[self.phases[i]].state_variables = sorted([v.T, v.P, v.N, v.GE], key=str)
self.models[self.phases[i]].state_variables = self.stateVariables

self.phase_records = PhaseRecordFactory(self.db, self.elements,
self.models[self.phases[0]].state_variables,
Expand Down Expand Up @@ -169,12 +170,13 @@ def _buildMobilityModels(self):

if len(phase_mob_params[p]) > 0 or len(phase_diff_params[p]) > 0:
self.mobModels[p] = MobilityModel(self.db, self.elements, p, parameters=param_keys)
self.mobModels[p].state_variables = sorted([v.T, v.P, v.N, v.GE], key=str)
self.mobModels[p].state_variables = self.stateVariables

mob_phases = list(self.mobModels.keys())
self.mob_phase_records = PhaseRecordFactory(self.db, self.elements,
self.mobModels[mob_phases[0]].state_variables,
self.mobModels, parameters=self._parameters)
if len(mob_phases) > 0:
self.mob_phase_records = PhaseRecordFactory(self.db, self.elements,
self.stateVariables,
self.mobModels, parameters=self._parameters)

for p in self.mobModels:
if len(phase_mob_params[p]) > 0:
Expand Down
Loading