use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class EcoSpold2Export method mapExchanges.
private void mapExchanges(Process process, DataSet ds) {
if (ds.flowData == null)
ds.flowData = new FlowData();
for (Exchange exchange : process.exchanges) {
if (!isValid(exchange))
continue;
Flow flow = exchange.flow;
UserMasterData masterData = ds.masterData;
if (flow.flowType == FlowType.ELEMENTARY_FLOW) {
ElementaryExchange e = createElemExchange(exchange, masterData);
ds.flowData.elementaryExchanges.add(e);
} else {
IntermediateExchange e = createIntermediateExchange(exchange, process, masterData);
ds.flowData.intermediateExchanges.add(e);
}
}
}
use of org.openlca.core.model.Exchange 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.model.Exchange 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.Exchange in project olca-modules by GreenDelta.
the class ParameterReferencesTest method createExchange.
private Exchange createExchange(String formula, Uncertainty u) {
Exchange e = new Exchange();
e.formula = formula;
e.uncertainty = u;
return e;
}
use of org.openlca.core.model.Exchange in project olca-modules by GreenDelta.
the class ProcessTest method addProvider.
private Process addProvider(Process p, Process provider, ProcessDao dao) {
Exchange in = createExchange(p, provider.quantitativeReference.flow, provider);
in.isInput = true;
p.exchanges.add(in);
return dao.update(p);
}
Aggregations