use of org.openlca.core.database.ImpactMethodDao in project olca-modules by GreenDelta.
the class RefSwitcher method getDestImpactMethodId.
Long getDestImpactMethodId(Long srcMethodId) {
if (srcMethodId == null)
return null;
ImpactMethodDao srcDao = new ImpactMethodDao(source);
ImpactMethodDescriptor srcDescriptor = srcDao.getDescriptor(srcMethodId);
if (srcDescriptor == null)
return null;
return seq.get(seq.IMPACT_METHOD, srcDescriptor.refId);
}
use of org.openlca.core.database.ImpactMethodDao in project olca-modules by GreenDelta.
the class Sequence method init.
private void init(IDatabase db) {
index(CATEGORY, new CategoryDao(db));
index(LOCATION, new LocationDao(db));
index(ACTOR, new ActorDao(db));
index(SOURCE, new SourceDao(db));
index(UNIT, new UnitDao(db));
index(UNIT_GROUP, new UnitGroupDao(db));
index(FLOW_PROPERTY, new FlowPropertyDao(db));
index(FLOW, new FlowDao(db));
index(CURRENCY, new CurrencyDao(db));
index(PROCESS, new ProcessDao(db));
index(PRODUCT_SYSTEM, new ProductSystemDao(db));
index(IMPACT_CATEGORY, new ImpactCategoryDao(db));
index(IMPACT_METHOD, new ImpactMethodDao(db));
index(NW_SET, new NwSetDao(db));
index(PROJECT, new ProjectDao(db));
index(DQ_SYSTEM, new DQSystemDao(db));
index(SOCIAL_INDICATOR, new SocialIndicatorDao(db));
}
use of org.openlca.core.database.ImpactMethodDao in project olca-modules by GreenDelta.
the class MethodImport method run.
@Override
public void run() {
ImpactMethodDao dao = new ImpactMethodDao(db);
Spold2Files.parse(files, es2 -> {
if (es2.impactMethod == null)
return;
ImpactMethod m = dao.getForRefId(es2.impactMethod.id);
if (m != null) {
log.warn("an LCIA method with id={} " + "already exisis; not imported", m.refId);
return;
}
m = map(es2.impactMethod);
if (m != null) {
dao.insert(m);
log.info("saved new LCIA method {}", m);
}
});
}
use of org.openlca.core.database.ImpactMethodDao 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.ImpactMethodDao in project olca-modules by GreenDelta.
the class CalculationExample method main.
public static void main(String[] args) {
Julia.load();
try (var db = Derby.fromDataDir("ei22")) {
var system = db.get(ProductSystem.class, "7d1cbce0-b5b3-47ba-95b5-014ab3c7f569");
var method = new ImpactMethodDao(db).getForRefId("207ffac9-aaa8-401d-ac90-874defd3751a");
var setup = CalculationSetup.fullAnalysis(system).withImpactMethod(method);
var calc = new SystemCalculator(db);
var r = calc.calculateFull(setup);
var f = r.enviIndex().at(0);
System.out.println(f.flow().name + " -> " + r.getTotalFlowResult(f));
var impact = r.impactIndex().at(0);
System.out.println(impact.name + " -> " + r.getTotalImpactResult(impact));
}
}
Aggregations