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

Integrate steel/ammonia models into run_simulation #280

Merged
merged 12 commits into from
Mar 6, 2024

Conversation

camirmas
Copy link
Collaborator

@camirmas camirmas commented Mar 4, 2024

Integrate steel/ammonia models into run_simulation

  • Runs black autoformatter on simulation greenheart_simulation.py
  • Refactors test_greenheart_system to use pytest and subtests
  • Proposes structure for YAML inputs (see greenheart_config_offshore.yaml)
  • Integrates steel/ammonia into run_simulation. Considering refactoring into convenience methods that exist in their respective modules (i.e. steel.py,ammonia.py) (EDIT: This is complete)
  • Adds new output_level that includes steel/ammonia finance outputs. I'm a bit unclear about the purpose behind output_levels, but it may be worth considering consolidating into an output dataclass with Optional fields for easier use and documentation
  • Adds new integration test to test_greenheart_system ensuring that we get finance outputs. We'll probably need to come back to these to make sure the values make sense

Similar to HOPP, the YAML structure for greenheart steel/ammonia configs matches their respective input dataclasses (CapacityModelConfig, CostModelConfig, FinanceModelConfig).

For example:

ammonia:
  capacity:
    input_capacity_factor_estimate: 0.9
  costs:
    feedstocks:
      electricity_cost: 89.42320514456621
      hydrogen_cost: 4.2986685034417045
      cooling_water_cost: 0.00291
      iron_based_catalyst_cost: 23.19977341
      oxygen_cost: 0
  finances:
    plant_life: 30
    grid_prices:
      "2035": 89.42320514456621
      "2036": 89.97947569251141
      "2037": 90.53574624045662
      "2038": 91.09201678840184
      "2039": 91.64828733634704
      "2040": 92.20455788429224
      "2041": 89.87291235917809
      "2042": 87.54126683406393
      "2043": 85.20962130894978
      "2044": 82.87797578383562
      "2045": 80.54633025872147
      "2046": 81.38632144593608
      "2047": 82.22631263315068
      "2048": 83.0663038203653
      "2049": 83.90629500757991
      "2050": 84.74628619479452
      "2051": 84.74628619479452
      "2052": 84.74628619479452
      "2053": 84.74628619479452
      "2054": 84.74628619479452
      "2055": 84.74628619479452
      "2056": 84.74628619479452
      "2057": 84.74628619479452
      "2058": 84.74628619479452
      "2059": 84.74628619479452
      "2060": 84.74628619479452
      "2061": 84.74628619479452
      "2062": 84.74628619479452
      "2063": 84.74628619479452
      "2064": 84.74628619479452

    # Additional parameters passed to ProFAST
    financial_assumptions:
      "total income tax rate": 0.2574
      "capital gains tax rate": 0.15
      "leverage after tax nominal discount rate": 0.10893
      "debt equity ratio of initial financing": 0.624788
      "debt interest rate": 0.050049

Related issue

Impacted areas of the software

Additional supporting information

Test results, if applicable

Copy link
Collaborator

@jaredthomas68 jaredthomas68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor comments, I think we can go ahead and merge

)

if "steel" in greenheart_config:
if verbose:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to say that the bulk of the code inside the if "steel".... statement should be in its own function to keep the simulation code cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I'll move it out

steel_finance = run_steel_finance_model(steel_finance_config)

if "ammonia" in greenheart_config:
if verbose:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for steel

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about this changing the config dictionary. That feels a little dangerous. Let's discuss this in our code meeting.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. As it currently stands, this will overwrite some configs even if the user does not want that. I was thinking one option is to first check if the necessary field is user-provided, and calculate if not

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be best to create an output data class where outputs can be stored. We should probably have a separate entry in the Greensteel config for steel and ammonia to specify if the user provided LCOH or the calculated LCOH should be used so the knock-on effects of providing an LCOH at input are clear.

This is likely to change as we refactor to use dataclasses for our simulation
config, but for now, this will make sure that we dont:

- override user configs for steel/ammonia
- modify the config `dict` unnecessarily

There's definitely a more refined interface solution that can accommodate scenarios
where the user does/doesn't want capacity calculations to be run, but this
should make the behavior a bit more predictable for now.
@camirmas
Copy link
Collaborator Author

camirmas commented Mar 5, 2024

I added some measures to mitigate override issues, but I'm going to revisit this in more detail when I work on configs next. I think it's important to clearly define where we may be overriding certain config values as we go through the steel/ammonia model steps, and to allow users to opt out by providing their own values, where appropriate

@jaredthomas68
Copy link
Collaborator

I think we can merge this as long as we have an issue made to address the config override problem more clearly.

@camirmas
Copy link
Collaborator Author

camirmas commented Mar 6, 2024

#283

@camirmas camirmas merged commit 77e049e into NREL:greensteel-eco-sync Mar 6, 2024
4 checks passed
@camirmas camirmas deleted the greensteel-eco-sync branch March 6, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants