0 votes
62 views

Dear all,

I am referring to a question Parameterized calculation setups in python - ask.openLCA - Question and Answer (Q&A) on Life Cycle Assessment (LCA) - A Life Cycle Assessment (LCA) Community in 2020, which matches my needs, but I think there is a change in syntax between OpenLCA 1.x and 2.x.

I have a parametrized model in my database, want to change the parameters via the ParameterReDef and run the calculation by a phyton script. In the documentation there is an example for the redefinition of one parameter. I have adapted the code to my needs to cover this issue but I am not sure if this is the right way.

myPSystem=client.get_descriptors(schema.ProductSystem, "36db6ce6-5575-410d-9933-ecfb66db35f0")
myPSystem_par=client.get_parameters(schema.ProductSystem,"36db6ce6-5575-410d-9933-ecfb66db35f0")
 
# Ansteuern des IPC Servers
setup = schema.CalculationSetup(
        target=myPSystem,
        impact_method=schema.Ref(id="c45bb4f6-8b50-425f-a4f6-c69668d7ac96"),
        parameters=[schema.ParameterRedef(name=myPSystem_par[1].name, value=4000,context=myPSystem_par[1].context),
                    schema.ParameterRedef(name=myPSystem_par[2].name, value=250,context=myPSystem_par[1].context)],
amount=inputs["fnctionalunit"])

Kind regards,

Dieter

in openLCA by (700 points)

1 Answer

+1 vote
by (7.1k points)
Hi Dieter,

This is the way to do it indeed. Be careful, the context of the second parameter redefinition might be wrong as you are using the index 1 and not 2.

Is something not working?

Regards,

François
by (700 points)
Thanks for your fast confirmation! I really was not sure if it is right or wrong (i was confused by the post of 2020). The first parameter on position 0 is a global one which I don´t need so start number will be 1 and ascending.

Kind regards,
Dieter
...