Search in sources :

Example 16 with FlowDescriptor

use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.

the class ProcessTable method getProviders.

/**
 * Returns the list of providers that have the flow with the given ID as
 * product output or waste input.
 */
public List<TechFlow> getProviders(long flowId) {
    TLongArrayList list = flowProviders.get(flowId);
    if (list == null)
        return Collections.emptyList();
    FlowDescriptor flow = flows.get(flowId);
    if (flow == null)
        return Collections.emptyList();
    ArrayList<TechFlow> providers = new ArrayList<>();
    list.forEach(id -> {
        var d = processes.get(id);
        if (d != null) {
            providers.add(TechFlow.of(d, flow));
        }
        return true;
    });
    return providers;
}
Also used : TLongArrayList(gnu.trove.list.array.TLongArrayList) FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) TechFlow(org.openlca.core.matrix.index.TechFlow) ArrayList(java.util.ArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList)

Example 17 with FlowDescriptor

use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.

the class CellWriter method flow.

private void flow(Sheet sheet, int row, int col, EnviFlow flow, boolean isRow) {
    if (flow == null || flow.flow() == null)
        return;
    FlowDescriptor f = flow.flow();
    cell(sheet, isRow ? row : row++, !isRow ? col : col++, f.refId, false);
    cell(sheet, isRow ? row : row++, !isRow ? col : col++, f.name, false);
    CategoryPair flowCat = CategoryPair.create(f, cache);
    cell(sheet, isRow ? row : row++, !isRow ? col : col++, flowCat.getCategory(), false);
    cell(sheet, isRow ? row : row++, !isRow ? col : col++, flowCat.getSubCategory(), false);
    cell(sheet, isRow ? row : row++, !isRow ? col : col++, flowUnit(f), false);
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) CategoryPair(org.openlca.io.CategoryPair)

Example 18 with FlowDescriptor

use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.

the class SolverTest method testSolve1x1System.

@Theory
public void testSolve1x1System(MatrixSolver solver) {
    log.info("Test solve 1x1 matrix with {}", solver.getClass());
    MatrixData data = new MatrixData();
    FlowDescriptor flow = new FlowDescriptor();
    flow.id = 1;
    ProcessDescriptor process = new ProcessDescriptor();
    process.id = 1;
    TechFlow provider = TechFlow.of(process, flow);
    TechIndex techIndex = new TechIndex(provider);
    techIndex.setDemand(1d);
    data.techIndex = techIndex;
    EnviIndex enviIndex = EnviIndex.create();
    enviIndex.add(EnviFlow.inputOf(flow(1)));
    enviIndex.add(EnviFlow.inputOf(flow(2)));
    enviIndex.add(EnviFlow.outputOf(flow(3)));
    enviIndex.add(EnviFlow.outputOf(flow(4)));
    data.enviIndex = enviIndex;
    Matrix techMatrix = solver.matrix(1, 1);
    techMatrix.set(0, 0, 1);
    data.techMatrix = techMatrix;
    Matrix enviMatrix = solver.matrix(4, 1);
    for (int r = 0; r < 4; r++) enviMatrix.set(r, 0, r);
    data.enviMatrix = enviMatrix;
    var result = SimpleResult.of(Tests.getDb(), data);
    Assert.assertArrayEquals(new double[] { 0, 1, 2, 3 }, result.totalFlowResults(), 1e-14);
}
Also used : EnviIndex(org.openlca.core.matrix.index.EnviIndex) Matrix(org.openlca.core.matrix.format.Matrix) FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) TechFlow(org.openlca.core.matrix.index.TechFlow) MatrixData(org.openlca.core.matrix.MatrixData) TechIndex(org.openlca.core.matrix.index.TechIndex) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) DataPoint(org.junit.experimental.theories.DataPoint) Theory(org.junit.experimental.theories.Theory)

Example 19 with FlowDescriptor

use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.

the class FlowIndexTest method randFlow.

private FlowDescriptor randFlow() {
    FlowDescriptor flow = new FlowDescriptor();
    flow.id = nextID++;
    flow.name = "Flow " + flow.id;
    return flow;
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor)

Example 20 with FlowDescriptor

use of org.openlca.core.model.descriptors.FlowDescriptor in project olca-modules by GreenDelta.

the class LinkContributionsTest method provider.

private TechFlow provider(long id, long flowId) {
    ProcessDescriptor process = new ProcessDescriptor();
    process.name = "Process " + id;
    process.id = id;
    FlowDescriptor flow = new FlowDescriptor();
    flow.name = "Flow " + flowId;
    flow.id = flowId;
    return TechFlow.of(process, flow);
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor)

Aggregations

FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)26 ArrayList (java.util.ArrayList)9 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)9 CostResultDescriptor (org.openlca.app.util.CostResultDescriptor)4 FlowDao (org.openlca.core.database.FlowDao)4 ImpactDescriptor (org.openlca.core.model.descriptors.ImpactDescriptor)4 ProcessDao (org.openlca.core.database.ProcessDao)3 TechFlow (org.openlca.core.matrix.index.TechFlow)3 Location (org.openlca.core.model.Location)3 CategoryPair (org.openlca.io.CategoryPair)3 JsonArray (com.google.gson.JsonArray)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 EntityCache (org.openlca.core.database.EntityCache)2 FlowType (org.openlca.core.model.FlowType)2 ProcessLink (org.openlca.core.model.ProcessLink)2 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)2 Contribution (org.openlca.core.results.Contribution)2 ProcessInstance (org.openlca.ilcd.models.ProcessInstance)2