use of org.openlca.core.model.AllocationFactor in project olca-modules by GreenDelta.
the class TestProcess method alloc.
/**
* Adds an economic or physical allocation factor with a formula for the
* given flow and method to the process. Use this method *after* the
* exchanges are added.
*/
public TestProcess alloc(String flow, AllocationMethod method, String formula) {
AllocationFactor f = new AllocationFactor();
f.method = method;
Exchange e = findExchange(process, flow);
f.productId = e.flow.id;
f.formula = formula;
process.allocationFactors.add(f);
return this;
}
use of org.openlca.core.model.AllocationFactor in project olca-modules by GreenDelta.
the class AllocationSheet method readRowFactors.
private AllocationFactor[] readRowFactors(int row, List<Exchange> products) {
String name = config.getString(sheet, row, 0);
Exchange product = getProduct(name, products);
if (product == null)
return null;
AllocationFactor[] factors = new AllocationFactor[2];
factors[0] = new AllocationFactor();
factors[0].productId = product.flow.id;
factors[0].value = config.getDouble(sheet, row, 2);
factors[0].method = AllocationMethod.PHYSICAL;
factors[1] = new AllocationFactor();
factors[1].productId = product.flow.id;
factors[1].value = config.getDouble(sheet, row, 3);
factors[1].method = AllocationMethod.ECONOMIC;
return factors;
}
use of org.openlca.core.model.AllocationFactor in project olca-modules by GreenDelta.
the class AllocationSheet method createCausalFactors.
private void createCausalFactors(int row, Exchange exchange, HashMap<Integer, Long> productColumnMap) {
for (Integer col : productColumnMap.keySet()) {
Long productId = productColumnMap.get(col);
if (col == null || productId == null)
continue;
AllocationFactor factor = new AllocationFactor();
factor.method = AllocationMethod.CAUSAL;
factor.productId = productId;
factor.value = config.getDouble(sheet, row, col);
factor.exchange = exchange;
process.allocationFactors.add(factor);
}
}
use of org.openlca.core.model.AllocationFactor in project olca-modules by GreenDelta.
the class EcoSpold01Import method mapAllocations.
private void mapAllocations(Process process, List<IAllocation> allocations) {
for (IAllocation allocation : allocations) {
double factor = Math.round(allocation.getFraction() * 10000d) / 1000000d;
Exchange product = localExchangeCache.get(allocation.getReferenceToCoProduct());
for (Integer i : allocation.getReferenceToInputOutput()) {
Exchange e = localExchangeCache.get(i);
if (e == null) {
log.warn("allocation factor points to an exchange that " + "does not exist: " + i);
continue;
}
AllocationFactor af = new AllocationFactor();
af.productId = product.flow.id;
af.value = factor;
af.method = AllocationMethod.CAUSAL;
af.exchange = e;
process.allocationFactors.add(af);
}
}
}
use of org.openlca.core.model.AllocationFactor in project olca-app by GreenDelta.
the class AllocationSync method setNewValues.
private void setNewValues(List<F> factors, AllocationMethod method) {
for (F f : factors) {
AllocationFactor factor = getFactor(f.product, method);
if (factor == null)
continue;
factor.value = f.value;
}
}
Aggregations