Search in sources :

Example 1 with AllocationFactor

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;
}
Also used : Exchange(org.openlca.core.model.Exchange) AllocationFactor(org.openlca.core.model.AllocationFactor)

Example 2 with AllocationFactor

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;
}
Also used : Exchange(org.openlca.core.model.Exchange) AllocationFactor(org.openlca.core.model.AllocationFactor)

Example 3 with AllocationFactor

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);
    }
}
Also used : AllocationFactor(org.openlca.core.model.AllocationFactor)

Example 4 with AllocationFactor

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);
        }
    }
}
Also used : IExchange(org.openlca.ecospold.IExchange) Exchange(org.openlca.core.model.Exchange) IAllocation(org.openlca.ecospold.IAllocation) AllocationFactor(org.openlca.core.model.AllocationFactor)

Example 5 with AllocationFactor

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;
    }
}
Also used : AllocationFactor(org.openlca.core.model.AllocationFactor)

Aggregations

AllocationFactor (org.openlca.core.model.AllocationFactor)12 Exchange (org.openlca.core.model.Exchange)6 JsonObject (com.google.gson.JsonObject)3 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)1 AllocationMethod (org.openlca.core.model.AllocationMethod)1 Flow (org.openlca.core.model.Flow)1 IAllocation (org.openlca.ecospold.IAllocation)1 IExchange (org.openlca.ecospold.IExchange)1