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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations