use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.
the class UncertaintyTableTest method createUncertainty.
private Uncertainty createUncertainty() {
Uncertainty uncertainty = Uncertainty.triangle(1, 2, 3);
uncertainty.formula1 = "0.5 * 2";
uncertainty.formula2 = "4 / 2";
uncertainty.formula3 = "4 / 2";
return uncertainty;
}
use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.
the class UncertaintyTableTest method testForExchange.
@Test
public void testForExchange() throws Exception {
Exchange exchange = new Exchange();
Uncertainty uncertainty = createUncertainty();
exchange.uncertainty = uncertainty;
Process process = new Process();
process.exchanges.add(exchange);
ProcessDao dao = new ProcessDao(database);
dao.insert(process);
Set<Long> set = new HashSet<>();
set.add(process.id);
List<CalcExchange> exchanges = cache.getExchangeCache().get(process.id);
checkExchange(exchanges.get(0));
dao.delete(process);
}
use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.
the class ParameterReferencesTest method testImpactFactorUncertainty.
@Test
public void testImpactFactorUncertainty() {
Parameter p1 = createParameter("p1", null, null, null);
Parameter p1Intern = createParameter("p1", null, ParameterScope.PROCESS, null);
Parameter p2 = createParameter("p2", null, null, null);
Uncertainty u1 = createUncertainty("1", "2", "3*p2");
Uncertainty u2 = createUncertainty("p1", "2*p1", "3*p2");
ImpactFactor f1 = createImpactFactor("2", u1);
ImpactFactor f2 = createImpactFactor("2", u2);
ImpactCategory impact = createImpactCategory(new ImpactFactor[] { f1, f2 }, new Parameter[] { p1Intern });
with((store) -> {
JsonExport export = new JsonExport(db, store);
export.write(impact);
assertNotNull(store.get(ModelType.IMPACT_CATEGORY, impact.refId));
assertNull(store.get(ModelType.PARAMETER, p1.refId));
assertNull(store.get(ModelType.PARAMETER, p1Intern.refId));
assertNotNull(store.get(ModelType.PARAMETER, p2.refId));
});
}
use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.
the class ParameterReferencesTest method testParameterUncertainty.
@Test
public void testParameterUncertainty() {
Uncertainty u2 = createUncertainty("1", "2", "3*p4");
Uncertainty u4 = createUncertainty("p1", "2*p1", "3*p2");
Parameter p1 = createParameter("p1", null, null, null);
Parameter p2 = createParameter("p2", "2*2", null, u2);
Parameter p3 = createParameter("p3", null, null, null);
Parameter p4 = createParameter("p4", "2*2", null, u4);
with((store) -> {
JsonExport export = new JsonExport(db, store);
export.write(p4);
assertNotNull(store.get(ModelType.PARAMETER, p1.refId));
assertNotNull(store.get(ModelType.PARAMETER, p2.refId));
assertNull(store.get(ModelType.PARAMETER, p3.refId));
assertNotNull(store.get(ModelType.PARAMETER, p4.refId));
});
}
use of org.openlca.core.model.Uncertainty in project olca-modules by GreenDelta.
the class ParameterReferencesTest method createUncertainty.
private Uncertainty createUncertainty(String f1, String f2, String f3) {
if (f3 == null) {
Uncertainty u = Uncertainty.logNormal(1, 1);
u.formula1 = f1;
u.formula2 = f2;
return u;
}
Uncertainty u = Uncertainty.triangle(1, 1, 1);
u.formula1 = f1;
u.formula2 = f2;
u.formula3 = f3;
return u;
}
Aggregations