Laboratory-for-Energy-Systems-Analysis / carculator_truck

Prospective life cycle assessment of medium and heavy duty vehicles
BSD 3-Clause "New" or "Revised" License
18 stars 4 forks source link

Manipulating default parameters of battery design #7

Closed nijeka93 closed 4 weeks ago

nijeka93 commented 2 months ago

For a research project I want to look at the trade-off between integrated battery design (=higher energy density) and modular design (=higher value retention). For that I need to adapt the original default parameters of: 'battery cell energy density', 'battery cell energy density, LFP', 'battery cell energy density, LTO', 'battery cell energy density, NCA', 'battery cell energy density, NMC', 'battery cell mass', 'battery cell mass share', 'battery cell mass share, LFP', 'battery cell mass share, LTO', 'battery cell mass share, NCA', 'battery cell mass share, NMC', 'battery cell power density', and 'battery cycle life'. Is there a way to do it? I tried adapting the 'amount' values in the "default_parameters.json" file, but it doesn't seem to work...

Thank you a lot for your help!

Best regards from Austria

nijeka93 commented 2 months ago

...found model.py, in which I could adapt those values - however, doesn't seem like the most elegant way adjusting them there...?

romainsacchi commented 2 months ago

Hi @nijeka93 you can try to set those values like so:

tip = TruckInputParameters()
#tip.stochastic(5)
tip.static()
dcts, array = fill_xarray_from_input_parameters(
    tip,
    scope={"year": [2020, 2030, 2040, 2050], "powertrain": ["BEV",], "size": ["40t"]},
)

array.loc[dict(parameter="battery cell energy density, NCA", value=0)] = [0.1, 0.2, 0.3, 0.4] # a different density for each year, for ex.

tm = TruckModel(
    array,
    cycle='Regional delivery',
    energy_storage={
        "electric": {
            ("BEV", "40t", 2020): "NCA"
        },
        "origin": "CN"
    }
)
tm.set_all()

You can then see that energy battery mass is affected accordingly. Same goes for the other parameters you list.

nijeka93 commented 2 months ago

Thank you very much, that is exactly what I was searching for!

nijeka93 commented 1 month ago

...what about the parameters that are calculated? It seems that setting e.g. "battery cycle life" like this: array.loc[dict(parameter="battery cycle life", value = 0)] = [5000] # NOT working doesn't have any effect on the LCA results -> I assume it is overriden by the model calculation for this variable afterwards...? Is there a way to define calculated model variables like "battery cycle life" as well?

nijeka93 commented 4 weeks ago

unfortunately, I cannot figure out where "battery cycle life" is originally set in the code or how I can adapt the set value. I tried: 1)

dcts, array = fill_xarray_from_input_parameters(
    tip,
    scope={"year": [2030], "powertrain": ["BEV",], "size": ["40t"]},
)

array.loc[dict(parameter="battery cycle life", value = 0)] = [5000]

tm = TruckModel(
    array,
    cycle='Regional delivery',
    energy_storage={
        "electric": {
            ("BEV", "40t", 2030): "NMC"
        },
        "origin": "CN"
    }
)
tm.set_all()

2)

dcts, array = fill_xarray_from_input_parameters(
    tip,
    scope={"year": [2030], "powertrain": ["BEV",], "size": ["40t"]},
)

tm = TruckModel(
    array,
    cycle='Regional delivery',
    energy_storage={
        "electric": {
            ("BEV", "40t", 2030): "NMC"
        },
        "origin": "CN"
    }
)
tm.set_all()

tm.array.loc[dict(parameter="battery cycle life", value = 0)] = [5000]

3) ...and changing the value in _/carculator_truck-master/carculator_truck/data/defaultparameters.json directly. Non seem to work.

PS: maybe of interest for others, one can change (some) calculated TruckModel parameters as shown in the second attempt, like e.g. the "battery lifetime replacements":

dcts, array = fill_xarray_from_input_parameters(
    tip,
    scope={"year": [2030], "powertrain": ["BEV",], "size": ["40t"]},
)

tm = TruckModel(
    array,
    cycle='Regional delivery',
    energy_storage={
        "electric": {
            ("BEV", "40t", 2030): "NMC"
        },
        "origin": "CN"
    }
)
tm.set_all()

tm.array.loc[dict(parameter="battery lifetime replacements", value = 0)] = [2.4]
romainsacchi commented 4 weeks ago

Hi @nijeka93, battery cycle life is some sort of placeholder parameter, not a calculated one. It is used to see whether replacement is needed or not: https://github.com/romainsacchi/carculator_truck/blob/ab489eebf5f14ee9fb2dc2997238f36cab4e360d/carculator_truck/model.py#L438

However, note that battery cycle life isn't in the json file, because it is not known yet which chemistry will be used. battery cycle life is defined once the chemistry is known, that is here: https://github.com/romainsacchi/carculator_utils/blob/a2d6e6c02bb90b76e2ef38a07e228c27e7afcaba/carculator_utils/model.py#L180

Once the chemistry is known battery cycle life, XXX gives it value to battery cycle life. So maybe try to set a value for battery cycle life, XXX before instantiating TruckModel(). This should give the corresponding value to battery cycle life, then considered during .set_all(), with XXX being one of:

nijeka93 commented 4 weeks ago

Thank you very much for the explanation!