use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class FormulaInterpreterTest method tearDown.
@After
public void tearDown() {
new ParameterDao(db).delete(globalParam);
new ProcessDao(db).delete(process);
}
use of org.openlca.core.database.ProcessDao 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.database.ProcessDao in project olca-modules by GreenDelta.
the class DQResultTest method setup.
@Before
public void setup() {
var units = db.insert(UnitGroup.of("Mass units", Unit.of("kg")));
var mass = db.insert(FlowProperty.of("Mass", units));
var product1 = db.insert(Flow.product("product 1", mass));
pFlow2 = db.insert(Flow.product("product 2", mass));
eFlow1 = db.insert(Flow.elementary("elem 1", mass));
eFlow2 = db.insert(Flow.elementary("elem 2", mass));
createDQSystem();
ProcessDao dao = new ProcessDao(db);
process1 = process(product1);
process1.quantitativeReference.dqEntry = "(1;2;3;4;5)";
process1.input(pFlow2, 2);
process1.input(eFlow1, 3).dqEntry = "(1;2;3;4;5)";
process1.input(eFlow2, 4).dqEntry = "(5;4;3;2;1)";
process1.dqEntry = "(1;2;3;4;5)";
process1 = dao.insert(process1);
process2 = process(pFlow2);
process2.quantitativeReference.dqEntry = "(5;4;3;2;1)";
process2.input(eFlow1, 5).dqEntry = "(5;4;3;2;1)";
process2.input(eFlow2, 6).dqEntry = "(1;2;3;4;5)";
process2.dqEntry = "(5;4;3;2;1)";
process2 = dao.insert(process2);
createProductSystem();
createImpactMethod();
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ParameterTableTest method tearDown.
@After
public void tearDown() {
IDatabase db = Tests.getDb();
new ParameterDao(db).deleteAll();
new ProcessDao(db).deleteAll();
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ParameterTableTest method setUp.
@Before
public void setUp() {
IDatabase db = Tests.getDb();
Parameter globalInp = inpParameter(42);
globalInp.scope = ParameterScope.GLOBAL;
Parameter globalDep = depParameter(2);
globalDep.scope = ParameterScope.GLOBAL;
ParameterDao paramDao = new ParameterDao(db);
paramDao.insert(globalInp);
paramDao.insert(globalDep);
process = new Process();
Parameter ppInp = inpParameter(84);
ppInp.scope = ParameterScope.PROCESS;
Parameter ppDep = depParameter(3);
ppDep.scope = ParameterScope.PROCESS;
process.parameters.add(ppInp);
process.parameters.add(ppDep);
new ProcessDao(db).insert(process);
}
Aggregations