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 the result state can be queried.

RESTPOST result/calculate
IPCresult/calculate
Python IPCClient.calculate
Return typeResultState
Parameter typeCalculationSetup

Examples

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)

JSON-RPC via Fetch API

The example below shows the usage of this method using the JSON-RPC protocol via the Fetch API which is available in modern web-browsers or platforms like Deno.

  let resp = await fetch("http://localhost:8080", {
    method: "POST",
    body: JSON.stringify({
      jsonrpc: "2.0",
      id: 1,
      method: "result/calculate",
      params: {
        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
      }
    })
  });
  let v = await resp.json();
  console.log(v);
  // {
  //   jsonrpc: "2.0",
  //   result: {
  //     "@id": "e316a369-bf5b-4c25-a61f-3492cfca9535",
  //     isReady: false,
  //     isScheduled: true,
  //     time: 1671187585187
  //   },
  //   id: 1
  // }