Search in sources :

Example 21 with ProcessDao

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);
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) ProcessDao(org.openlca.core.database.ProcessDao) After(org.junit.After)

Example 22 with ProcessDao

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 } });
}
Also used : Exchange(org.openlca.core.model.Exchange) FullResult(org.openlca.core.results.FullResult) ImpactMethodDao(org.openlca.core.database.ImpactMethodDao) ProcessDao(org.openlca.core.database.ProcessDao) Process(org.openlca.core.model.Process) ImpactCategory(org.openlca.core.model.ImpactCategory) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) ImpactMethod(org.openlca.core.model.ImpactMethod) Flow(org.openlca.core.model.Flow) EnviFlow(org.openlca.core.matrix.index.EnviFlow) TechFlow(org.openlca.core.matrix.index.TechFlow) Test(org.junit.Test)

Example 23 with ProcessDao

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();
}
Also used : ProcessDao(org.openlca.core.database.ProcessDao) Before(org.junit.Before)

Example 24 with ProcessDao

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();
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) After(org.junit.After)

Example 25 with ProcessDao

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);
}
Also used : ParameterDao(org.openlca.core.database.ParameterDao) IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) Parameter(org.openlca.core.model.Parameter) Process(org.openlca.core.model.Process) Before(org.junit.Before)

Aggregations

ProcessDao (org.openlca.core.database.ProcessDao)51 Process (org.openlca.core.model.Process)26 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)14 IDatabase (org.openlca.core.database.IDatabase)12 FlowDao (org.openlca.core.database.FlowDao)11 Test (org.junit.Test)10 ProductSystemDao (org.openlca.core.database.ProductSystemDao)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 ParameterDao (org.openlca.core.database.ParameterDao)5 HashMap (java.util.HashMap)4 Before (org.junit.Before)4 NativeSql (org.openlca.core.database.NativeSql)4 Exchange (org.openlca.core.model.Exchange)4 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)4 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 FlowPropertyDao (org.openlca.core.database.FlowPropertyDao)3 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)3 ImpactMethodDao (org.openlca.core.database.ImpactMethodDao)3