+1 vote

I have modified the example here to select multiple product systems (instead of processes) and export simple results to csv file. However, each product system is showing the same results (based on the first product system selected). These product systems rely on the same processes but different parameter values.

Is there something about this section of the code where something needs to be reset, perhaps in the calculator or the cache?

            # run the calculation
            print('Calculate system: %s' % d.name)
            calculator = SystemCalculator(
                Cache.getMatrixCache(), App.getSolver())
            setup = CalculationSetup(
                CalculationType.SIMPLE_CALCULATION, system)
            setup.impactMethod = method
            result = calculator.calculateSimple(setup)
in openLCA by (1.5k points)
by (3.5k points)
edited by
This is what I use to pull results from all product systems that exist in a given model. You could add a filter of sorts by changing the prod_systems list comprehension to include wanted text (e.g.[x for x in systems if "cool_product_" in x]). The results are a dictionary of dictionaries with product system names as keys and the results jsons as the values. This is using the IPC - it might be that you're trying to use something within the python window...that I don't really have experience with. I find it's generally much more painful to use the various methods for finding things like product systems using jython.

#This will return a "generator" with all product systems in the database.
systems = olca_client.get_all(model_type=olca.ProductSystem)

#We immdiately create a list of the product system names. The generator
#can only be used once. We'll use this list of names later.
prod_systems = [x.name for x in systems]

for prod_sys in prod_systems:
    calc_setup = olca.CalculationSetup()
    #While I change the calc type here, it really doesn't matter. Currently (10.10.2019)
    #olca-ipc returns SIMPLE_RESULT for everything
    calc_setup.calculation_type = olca.CalculationType.UPSTREAM_ANALYSIS
    #Use the name to find the product system
    calc_setup.product_system = olca_client.find(model_type=olca.ProductSystem,name=prod_sys)
    calc_setup.impact_method = impact_method
    #This is an optional step. if you omit this it should default to whatever's
    #specified in the database
    calc_setup.amount = 1.0
    #calculate! .calculate returns a "calculation" type from openLCA.

1 Answer

0 votes
by (11k points)

When you have a product system with parameter redefinitions, you need to add these parameter redefinitions from the system to the calculation setup before you run the calculation:


Otherwise these parameter redefinitions are not applied in the calculation. You also need to do this when you run the calculation via the IPC interface: https://github.com/GreenDelta/olca-ipc.py#parameterized-calculation-setups