Calculate results
This method schedules a new calculation for a given setup. It directly returns
a state object that contains the result ID (field @id). With this ID
the result state can be queried.
| Method | Parameters | Returns |
|---|---|---|
calculate | CalculationSetup | ResultState |
This is a method of the client and not of a result: via REST, it is
POST result/calculate with the calculation setup as request body; in Python,
it is Client.calculate.
Try it
You can edit and execute the example below. Just make sure an openLCA IPC
server is running on port 8080:
const v = await call("result/calculate", {
target: {
"@type": "ProductSystem",
"@id": "0db1eda6-a34e-4c82-b06b-19f27c92495a"
},
impactMethod: {
"@id": "b4571628-4b7b-3e4f-81b1-9a8cca6cb3f8",
},
nwSet: {
"@id": "867fe119-0b5c-38a0-a3e6-1d845ffaedd5",
},
withCosts: true,
amount: 1.0
});
console.log(v);
// {
// "@id": "e316a369-bf5b-4c25-a61f-3492cfca9535",
// isReady: false,
// isScheduled: true,
// time: 1671187585187
// }
Python IPC
import olca_ipc as ipc
import olca_schema as o
# create a calculation setup
setup = o.CalculationSetup(
target=o.Ref(
ref_type=o.RefType.ProductSystem,
id="0db1eda6-a34e-4c82-b06b-19f27c92495a",
),
impact_method=o.Ref(id="b4571628-4b7b-3e4f-81b1-9a8cca6cb3f8"),
nw_set=o.Ref(id="867fe119-0b5c-38a0-a3e6-1d845ffaedd5"),
)
# run a calculation
client = ipc.Client()
result: ipc.Result = client.calculate(setup)