Skip to content

Commit

Permalink
update steel names
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrunik committed Feb 28, 2024
1 parent ec4824d commit 130aa39
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
Empty file.
48 changes: 24 additions & 24 deletions greenheart/simulation/technologies/steel/steel.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,70 +192,70 @@ class SteelCostModelOutputs(SteelCosts):
misc_owners_costs: float

@define
class SteelSizeModelConfig:
class SteelCapacityModelConfig:
"""
Configuration inputs for the steel sizing model, including plant capacity and
Configuration inputs for the steel capacity sizing model, including plant capacity and
feedstock details.
Attributes:
hydrogen_amount_kg Optional (float): The amount of hydrogen available in kilograms
hydrogen_amount_kgpy Optional (float): The amount of hydrogen available in kilograms
per year to make steel.
steel_plant_size_mtpy Optional (float): The amount of desired steel production in
desired_steel_mtpy Optional (float): The amount of desired steel production in
metric tonnes per year.
plant_capcity_factor (float): The steel plant capacity factor.
feedstocks (Feedstocks): An instance of the `Feedstocks` class detailing the
costs and consumption rates of resources used in production.
"""
plant_capacity_factor: float
feedstocks: Feedstocks
hydrogen_amount_kg: Optional[float] = field(default=None)
steel_plant_size_mtpy: Optional[float] = field(default=None)
hydrogen_amount_kgpy: Optional[float] = field(default=None)
desired_steel_mtpy: Optional[float] = field(default=None)


def __attrs_post_init__(self):
if self.hydrogen_amount_kg is None and self.steel_plant_size_mtpy is None:
raise ValueError("`hydrogen_amount_kg` or `steel_plant_size_mtpy` is a required input.")
if self.hydrogen_amount_kgpy is None and self.desired_steel_mtpy is None:
raise ValueError("`hydrogen_amount_kgpy` or `desired_steel_mtpy` is a required input.")

if self.hydrogen_amount_kg and self.steel_plant_size_mtpy:
raise ValueError("can only select one input: `hydrogen_amount_kg` or `steel_plant_size_mtpy`.")
if self.hydrogen_amount_kgpy and self.desired_steel_mtpy:
raise ValueError("can only select one input: `hydrogen_amount_kgpy` or `desired_steel_mtpy`.")

@define
class SteelSizeModelOutputs:
class SteelCapacityModelOutputs:
"""
Outputs from the steel size model.
Attributes:
steel_plant_size_mtpy (float): If amount of hydrogen in kilograms per year is input,
the size of the steel plant in metric tonnes per year is output.
hydrogen_amount_kg (float): If amount of steel production in metric tonnes per year is input,
hydrogen_amount_kgpy (float): If amount of steel production in metric tonnes per year is input,
the amount of necessary hydrogen feedstock in kilograms per year is output.
"""
steel_plant_size_mtpy: float
hydrogen_amount_kg: float
steel_plant_capacity_mtpy: float
hydrogen_amount_kgpy: float

def run_size_steel_plant(config: SteelSizeModelConfig) -> SteelSizeModelOutputs:
def run_size_steel_plant_capcity(config: SteelCapacityModelConfig) -> SteelCapacityModelOutputs:

if config.hydrogen_amount_kg:
steel_plant_size_mtpy = (config.hydrogen_amount_kg
if config.hydrogen_amount_kgpy:
steel_plant_capacity_mtpy = (config.hydrogen_amount_kgpy
/ 1000
/ config.feedstocks.hydrogen_consumption
* config.plant_capacity_factor
)
hydrogen_amount_kg = config.hydrogen_amount_kg
hydrogen_amount_kgpy = config.hydrogen_amount_kgpy

if config.steel_plant_size_mtpy:
hydrogen_amount_kg = (config.steel_plant_size_mtpy
if config.desired_steel_mtpy:
hydrogen_amount_kgpy = (config.desired_steel_mtpy
* 1000
* config.feedstocks.hydrogen_consumption
/ config.plant_capacity_factor
)
steel_plant_size_mtpy = (config.steel_plant_size_mtpy
steel_plant_capacity_mtpy = (config.desired_steel_mtpy
/ config.plant_capacity_factor
)

return SteelSizeModelOutputs(
steel_plant_size_mtpy=steel_plant_size_mtpy,
hydrogen_amount_kg=hydrogen_amount_kg
return SteelCapacityModelOutputs(
steel_plant_capacity_mtpy=steel_plant_capacity_mtpy,
hydrogen_amount_kgpy=hydrogen_amount_kgpy
)

def run_steel_model(plant_capacity_mtpy: float, plant_capacity_factor: float) -> float:
Expand Down
22 changes: 11 additions & 11 deletions tests/greenheart/test_steel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pytest import approx, fixture

from greenheart.simulation.technologies import steel
from greenheart.simulation.technologies.steel import steel

ng_prices_dict = {
"2035": 3.76232,
Expand Down Expand Up @@ -139,33 +139,33 @@ def test_steel_finance_model(cost_config):
assert res.sol.get("price") == lcos_expected

def test_steel_size_h2_input(subtests):
config = steel.SteelSizeModelConfig(
hydrogen_amount_kg=73288888.8888889,
config = steel.SteelCapacityModelConfig(
hydrogen_amount_kgpy=73288888.8888889,
plant_capacity_factor=0.9,
feedstocks=steel.Feedstocks(
natural_gas_prices=ng_prices_dict, oxygen_market_price=0
),
)

res: steel.SteelSizeModelOutputs = steel.run_size_steel_plant(config)
res: steel.SteelCapacityModelOutputs = steel.run_size_steel_plant_capcity(config)

with subtests.test("steel plant size"):
assert res.steel_plant_size_mtpy == approx(1000000)
assert res.steel_plant_capacity_mtpy == approx(1000000)
with subtests.test("hydrogen input"):
assert res.hydrogen_amount_kg == approx(73288888.8888889)
assert res.hydrogen_amount_kgpy == approx(73288888.8888889)

def test_steel_size_NH3_input(subtests):
config = steel.SteelSizeModelConfig(
steel_plant_size_mtpy=1000000,
config = steel.SteelCapacityModelConfig(
desired_steel_mtpy=1000000,
plant_capacity_factor=0.9,
feedstocks=steel.Feedstocks(
natural_gas_prices=ng_prices_dict, oxygen_market_price=0
),
)

res: steel.SteelSizeModelOutputs = steel.run_size_steel_plant(config)
res: steel.SteelCapacityModelOutputs = steel.run_size_steel_plant_capcity(config)

with subtests.test("steel plant size"):
assert res.steel_plant_size_mtpy == approx(1111111.111111111)
assert res.steel_plant_capacity_mtpy == approx(1111111.111111111)
with subtests.test("hydrogen input"):
assert res.hydrogen_amount_kg == approx(73288888.8888889)
assert res.hydrogen_amount_kgpy == approx(73288888.8888889)

0 comments on commit 130aa39

Please sign in to comment.