use of org.openlca.core.results.FullResult in project olca-modules by GreenDelta.
the class RegionalizedCalculationTest method testRegionalizedCalculation.
@Test
public void testRegionalizedCalculation() {
Flow nox = flow("NOx", "mg", FlowType.ELEMENTARY_FLOW);
// create the process
Process p = new Process();
p.name = "transport, bus";
p.quantitativeReference = p.output(flow("transport, bus", "p*km", FlowType.PRODUCT_FLOW), 1);
Exchange e1 = p.output(nox, 5);
e1.location = loc1;
Exchange e2 = p.output(nox, 10);
e2.location = loc2;
p = new ProcessDao(db).insert(p);
// create the LCIA category & method
var impact = new ImpactCategory();
impact.name = "human tox";
impact.factor(nox, 0.5);
impact.factor(nox, 0.1).location = loc1;
impact.factor(nox, 0.9).location = loc2;
impact = new ImpactCategoryDao(db).insert(impact);
var method = new ImpactMethod();
method.impactCategories.add(impact);
method = new ImpactMethodDao(db).insert(method);
// create the product system and calculation setup
var setup = CalculationSetup.fullAnalysis(ProductSystem.of(p)).withImpactMethod(method).withRegionalization(true);
var calculator = new SystemCalculator(db);
FullResult r = calculator.calculateFull(setup);
Assert.assertTrue(r.enviIndex().isRegionalized());
checkRegTotalFlowResults(r, new Object[][] { { nox, loc1, 5.0 }, { nox, loc2, 10.0 } });
}
use of org.openlca.core.results.FullResult in project olca-modules by GreenDelta.
the class RegionalizedCalculationTest method checkNoLocations.
@Test
public void checkNoLocations() {
CalculationSetup setup = calcSetup();
SystemCalculator calc = new SystemCalculator(db);
FullResult r = calc.calculateFull(setup);
// total results
checkTotalFlowResults(r, new Object[][] { { e1, 2.0 }, { e2, 4.0 } });
checkTotalImpactResult(r, 14.0);
// direct contributions
checkDirectFlowResults(r, new Object[][] { { p1, e1, 2.0 }, { p1, e2, 0.0 }, { p2, e1, 0.0 }, { p2, e2, 4.0 } });
checkDirectImpactResults(r, new Object[][] { { p1, 2 * 3.0 }, { p2, 4 * 2.0 } });
// upstream contributions
checkUpstreamFlowResults(r, new Object[][] { { p1, e1, 2.0 }, { p1, e2, 4.0 }, { p2, e1, 0.0 }, { p2, e2, 4.0 } });
checkUpstreamImpactResults(r, new Object[][] { { p1, 14.0 }, { p2, 8.0 } });
}
use of org.openlca.core.results.FullResult in project olca-modules by GreenDelta.
the class AvoidedFlowsTest method check.
private void check(Process refProc, Process linkedProc) {
ProductSystem system = TestSystem.of(refProc).link(linkedProc).get();
FullResult r = TestSystem.calculate(system);
assertEquals(1, r.enviIndex().size());
EnviFlow co2 = r.enviIndex().at(0);
assertEquals(1.0, r.getTotalFlowResult(co2), 1e-16);
}
use of org.openlca.core.results.FullResult in project olca-modules by GreenDelta.
the class CostTests method testSimpleChain.
@Test
public void testSimpleChain() {
Process p1 = TestProcess.refProduct("p1", 1, "kg").addCosts("p1", 2, "EUR").elemIn("water", 1, "m3").addCosts("water", 5, "EUR").get();
Process p2 = TestProcess.refProduct("p2", 1, "kg").addCosts("p2", 5, "EUR").prodIn("p1", 2, "kg").addCosts("p1", 4, "EUR").get();
ProductSystem system = TestSystem.of(p2).link(p1).get();
FullResult r = TestSystem.calculate(system);
ProcessDescriptor d1 = Descriptor.of(p1);
ProcessDescriptor d2 = Descriptor.of(p2);
Assert.assertEquals(5, r.totalCosts(), 1e-10);
Assert.assertEquals(6, r.getDirectCostResult(d1), 1e-10);
Assert.assertEquals(-1, r.getDirectCostResult(d2), 1e-10);
Assert.assertEquals(6, r.getUpstreamCostResult(d1), 1e-10);
Assert.assertEquals(5, r.getUpstreamCostResult(d2), 1e-10);
}
use of org.openlca.core.results.FullResult in project olca-modules by GreenDelta.
the class CostTests method test.
@Test
public void test() {
Process electricity = TestProcess.refProduct("Electricity", 1, "MJ").addCosts("Electricity", 5, "EUR").elemOut("CO2", 3, "kg").get();
Process wood = TestProcess.refProduct("Wood", 1, "kg").addCosts("Wood", 1, "EUR").get();
Process chair = TestProcess.refProduct("Chair", 1, "piece").addCosts("Chair", 25, "EUR").prodIn("Electricity", 2, "MJ").addCosts("Electricity", 10, "EUR").prodIn("Wood", 5, "kg").addCosts("Wood", 5, "EUR").get();
Process disposal = TestProcess.refProduct("Disposal of chair", 1, "piece").addCosts("Disposal of chair", 2, "EUR").get();
Process usage = TestProcess.refProduct("Sitting", 10, "years").addCosts("Sitting", 135, "EUR").prodIn("Chair", 5, "piece").addCosts("Chair", 125, "EUR").prodIn("Disposal of chair", 5, "piece").addCosts("Disposal of chair", 10, "EUR").get();
ProductSystem system = TestSystem.of(usage).link(disposal).link(chair).link(wood).link(electricity).get();
// TODO: test something here
FullResult result = TestSystem.calculate(system);
System.out.println(result.totalCosts());
}
Aggregations