-
Notifications
You must be signed in to change notification settings - Fork 39
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
Added modular functions to model the production of Green Steel: #190
base: dev/refactor
Are you sure you want to change the base?
Changes from 1 commit
b700da0
07be05a
3c52f63
77f6314
a32b6e6
4bd7baf
131a1ee
3bb8db1
47826aa
97a766b
72f47f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,36 +19,55 @@ | |
H_t: Enthalpy of element at given temp (kj/g) | ||
''' | ||
|
||
def h2_enthalpy_1(T): | ||
def h2_enthalpy(T): | ||
mol_weight_H2=2.01588 #in grams# T1 and T2 should be in the range of 298-1000 K <br> | ||
t=T/1000 | ||
A=33.066718 | ||
B=-11.363417 | ||
C=11.432816 | ||
D=-2.772874 | ||
E=-0.158558 | ||
F=-9.980797 | ||
G=172.707974 | ||
H=0 | ||
H_t=A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H | ||
return H_t | ||
def h2_enthalpy_2(T): | ||
mol_weight_H2=2.01588#T in range 1000-2500 K | ||
t=T/1000 | ||
A=18.563083 | ||
B=12.257357 | ||
C=-2.859786 | ||
D=0.268238 | ||
E=1.977990 | ||
F=-1.147438 | ||
G=156.288133 | ||
H=0 | ||
H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_H2 | ||
return H_t | ||
if T < 298 or T > 2500: | ||
raise ValueError(f"Inputted temperatute {T} for hydrogen gas is out of range of 298-2500 K") | ||
|
||
if T < 1000: #h2_1 # T1 and T2 should be in the range of 298-1000 K <br> | ||
t=T/1000 | ||
A=33.066718 | ||
B=-11.363417 | ||
C=11.432816 | ||
D=-2.772874 | ||
E=-0.158558 | ||
F=-9.980797 | ||
G=172.707974 | ||
H=0 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_H2 | ||
|
||
if T >= 1000: #h2_2 #T in range 1000-2500 K | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be elif |
||
t=T/1000 | ||
A=18.563083 | ||
B=12.257357 | ||
C=-2.859786 | ||
D=0.268238 | ||
E=1.977990 | ||
F=-1.147438 | ||
G=156.288133 | ||
H=0 | ||
H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_H2 | ||
|
||
return H_t | ||
|
||
#def h2_enthalpy_2(T): | ||
#mol_weight_H2=2.01588#T in range 1000-2500 K | ||
#t=T/1000 | ||
#A=18.563083 | ||
#B=12.257357 | ||
#C=-2.859786 | ||
#D=0.268238 | ||
#E=1.977990 | ||
#F=-1.147438 | ||
#G=156.288133 | ||
#H=0 | ||
#H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_H2 | ||
#return H_t | ||
### Water enthalpy coefficients | ||
|
||
def h2o_enthalpy(T): | ||
mol_weight_H2O=18.0153 | ||
def h2o_enthalpy(T): # 500-1700 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needs temperature value error check |
||
|
||
mol_weight_H2O=18.0153 | ||
t=T/1000 | ||
A=30.09200 | ||
B=6.832514 | ||
|
@@ -59,36 +78,59 @@ def h2o_enthalpy(T): | |
G=223.3967 | ||
H=-241.8264 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_H2O | ||
|
||
return H_t | ||
|
||
def fe_enthalpy_1(T):#298-1809 K | ||
mol_weight_fe=55.845 #in grams | ||
t=T/1000 | ||
A=23.97449 | ||
B=8.367750 | ||
C=0.000277 | ||
D=-0.000088 | ||
E=-0.000005 | ||
F=0.268027 | ||
G=62.06336 | ||
H=7.788015 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_fe | ||
return H_t | ||
def fe_enthalpy_2(T):#1809 - 3133K | ||
|
||
|
||
def fe_enthalpy(T):#298-1809 K | ||
mol_weight_fe=55.845 #in grams | ||
t=T/1000 | ||
A=46.02400 | ||
B=-1.88467*10**(-8) | ||
C=6.094750*10**(-9) | ||
D=-6.640301*10**(-10) | ||
E=-0.8246121*10**(-9) | ||
F=-10.80543 | ||
G=72.54094 | ||
H=12.39052 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_fe | ||
|
||
if T < 298 or T > 3133: | ||
raise ValueError(f"Inputted temperatute {T} for iron is out of range of 298-3133 K") | ||
|
||
if T < 1809: #fe_1 298-1809 K | ||
t=T/1000 | ||
A=23.97449 | ||
B=8.367750 | ||
C=0.000277 | ||
D=-0.000088 | ||
E=-0.000005 | ||
F=0.268027 | ||
G=62.06336 | ||
H=7.788015 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_fe | ||
|
||
if T >= 1809: #fe_2 1809 - 3133K | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be elif |
||
t=T/1000 | ||
A=46.02400 | ||
B=-1.88467*10**(-8) | ||
C=6.094750*10**(-9) | ||
D=-6.640301*10**(-10) | ||
E=-0.8246121*10**(-9) | ||
F=-10.80543 | ||
G=72.54094 | ||
H=12.39052 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_fe | ||
|
||
return H_t | ||
|
||
#def fe_enthalpy_2(T):#1809 - 3133K | ||
#mol_weight_fe=55.845 #in grams | ||
#t=T/1000 | ||
#A=46.02400 | ||
#B=-1.88467*10**(-8) | ||
#C=6.094750*10**(-9) | ||
#D=-6.640301*10**(-10) | ||
#E=-0.8246121*10**(-9) | ||
#F=-10.80543 | ||
#G=72.54094 | ||
#H=12.39052 | ||
#H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_fe | ||
#return H_t | ||
|
||
def feo_enthalpy(T): | ||
mol_weight_feo=71.844 #in grams | ||
mol_weight_feo=71.844 #in grams 298-1650 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it looks like this and other value ranges should have been error checks on temperature, not in the comment on molecular weight |
||
t=T/1000 | ||
A=45.75120 | ||
B=18.78553 | ||
|
@@ -100,8 +142,9 @@ def feo_enthalpy(T): | |
H=-272.0441 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_feo | ||
return H_t | ||
|
||
def al2o3_enthalpy(T): | ||
mol_weight_al2o3=101.9613 #in grams | ||
mol_weight_al2o3=101.9613 #in grams 298-2327 | ||
t=T/1000 | ||
A=106.0880 | ||
B=36.33740 | ||
|
@@ -113,8 +156,9 @@ def al2o3_enthalpy(T): | |
H=-1662.300 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_al2o3 | ||
return H_t | ||
|
||
def sio2_enthalpy(T): | ||
mol_weight_Sio2=60.0843 #in grams | ||
mol_weight_Sio2=60.0843 #in grams 847-1996 | ||
t=T/1000 | ||
A=58.75 | ||
B=10.279 | ||
|
@@ -126,8 +170,9 @@ def sio2_enthalpy(T): | |
H=-910.8568 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_Sio2 | ||
return H_t | ||
|
||
def mgo_enthalpy(T): | ||
mol_weight_mgo=40.3044 #in grams | ||
mol_weight_mgo=40.3044 #in grams 298-3105 | ||
t=T/1000 | ||
A=47.25995 | ||
B=5.681621 | ||
|
@@ -139,8 +184,9 @@ def mgo_enthalpy(T): | |
H=-601.2408 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_mgo | ||
return H_t | ||
|
||
def cao_enthalpy(T): | ||
mol_weight_cao=56.077#in grams | ||
mol_weight_cao=56.077#in grams 298-3200 | ||
t=T/1000 | ||
A=49.95403 | ||
B=4.887916 | ||
|
@@ -152,32 +198,52 @@ def cao_enthalpy(T): | |
H=-635.0894 | ||
H_t=(A*t +(B*t*t)/2 +(C*t*t*t)/3 + (D*t*t*t*t)/4-(E/t)+F-H)/mol_weight_cao | ||
return H_t | ||
def ch4_enthalpy_1(T):# T in the range 298-1000 K | ||
mol_weight_CH4=16.04 # in grams | ||
t=T/1000 | ||
A=-0.703029 | ||
B=108.4773 | ||
C=-42.52157 | ||
D=5.862788 | ||
E=0.678565 | ||
F=-76.84376 | ||
G=158.7163 | ||
H=-74.87310 | ||
H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_CH4 | ||
return H_t | ||
def ch4_enthalpy_2(T):# T in range 1300-6000 K | ||
|
||
def ch4_enthalpy(T):# T in the range 298-1000 K | ||
mol_weight_CH4=16.04 # in grams | ||
t=T/1000 | ||
A=85.81217 | ||
B=11.26467 | ||
C=-2.114146 | ||
D=0.138190 | ||
E=-26.42221 | ||
F=-153.5327 | ||
G=224.4143 | ||
H=-74.87310 | ||
H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_CH4 | ||
if T < 298 or T > 6000: | ||
raise ValueError(f"Inputted temperatute {T} for methane gas is out of range of 298-6000 K") | ||
|
||
if T <= 1000: #1 298-1300 K | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be elif |
||
t=T/1000 | ||
A=-0.703029 | ||
B=108.4773 | ||
C=-42.52157 | ||
D=5.862788 | ||
E=0.678565 | ||
F=-76.84376 | ||
G=158.7163 | ||
H=-74.87310 | ||
H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_CH4 | ||
|
||
if T >1300: #2 1300-6000 K | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be elif |
||
t=T/1000 | ||
A=85.81217 | ||
B=11.26467 | ||
C=-2.114146 | ||
D=0.138190 | ||
E=-26.42221 | ||
F=-153.5327 | ||
G=224.4143 | ||
H=-74.87310 | ||
H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_CH4 | ||
|
||
return H_t | ||
|
||
#def ch4_enthalpy_2(T):# T in range 1300-6000 K | ||
#mol_weight_CH4=16.04 # in grams | ||
#t=T/1000 | ||
#A=85.81217 | ||
#B=11.26467 | ||
#C=-2.114146 | ||
#D=0.138190 | ||
#E=-26.42221 | ||
#F=-153.5327 | ||
#G=224.4143 | ||
#H=-74.87310 | ||
#H_t=(A*t +(B*t**2)/2 +(C*t**3)/3 + (D*t**4)/4-(E/t)+F-H)/mol_weight_CH4 | ||
#return H_t | ||
|
||
def c_enthalpy(T):# T in the range 298-1000 K | ||
mol_weight_C=12.017 # in grams | ||
t=T/1000 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import pytest | ||
import hopp.simulation.technologies.steel.enthalpy_functions as ep_f | ||
|
||
def test_h2_enthalpy_upper_function(): | ||
|
||
temp = 1500 | ||
|
||
assert pytest.approx(ep_f.h2_enthalpy(temp),.01) == 18.002 | ||
|
||
def test_h2_enthalpy_lower_function(): | ||
|
||
temp = 500 | ||
|
||
assert pytest.approx(ep_f.h2_enthalpy(temp),.01) == 2.91 | ||
|
||
def test_h2_enthalpy_error_function(): | ||
|
||
temp = 0 | ||
|
||
with pytest.raises(ValueError):ep_f.h2_enthalpy(temp) | ||
|
||
|
||
def test_h2o_enthalpy_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.h2o_enthalpy(temp),.01) == 1.443 | ||
|
||
def test_fe_enthalpy_upper_function(): | ||
|
||
temp = 2000 | ||
|
||
assert pytest.approx(ep_f.fe_enthalpy(temp),.01) == 1.23 | ||
|
||
def test_fe_enthalpy_lower_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.fe_enthalpy(temp),.01) == .369 | ||
|
||
|
||
def test_fe_enthalpy_error_function(): | ||
|
||
temp = 0 | ||
|
||
with pytest.raises(ValueError):ep_f.fe_enthalpy(temp) | ||
|
||
def test_feo_enthalpy_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.feo_enthalpy(temp),.01) == .5394 | ||
|
||
def test_al2o3_enthalpy_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.al2o3_enthalpy(temp),.01) == .781 | ||
|
||
def test_sio2_enthalpy_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.sio2_enthalpy(temp),.01) == .754 | ||
|
||
def test_mgo_enthalpy_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.mgo_enthalpy(temp),.01) == .818 | ||
|
||
def test_cao_enthalpy_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.cao_enthalpy(temp),.01) == .628 | ||
|
||
def test_ch4_enthalpy_upper_function(): | ||
|
||
temp = 1500 | ||
|
||
assert pytest.approx(ep_f.ch4_enthalpy(temp),.01) == 4.87 | ||
|
||
def test_ch4_enthalpy_lower_function(): | ||
|
||
temp = 1000 | ||
|
||
assert pytest.approx(ep_f.ch4_enthalpy(temp),.01) == 2.38 | ||
|
||
def test_ch4_enthalpy_error_function(): | ||
|
||
temp = 0 | ||
|
||
with pytest.raises(ValueError):ep_f.ch4_enthalpy(temp) | ||
|
||
def test_c_enthalpy_lower_function(): | ||
|
||
temp = 900 | ||
|
||
assert pytest.approx(ep_f.ch4_enthalpy(temp),.01) == 1.945 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elif