src/main/java/com/equinor/neqsim/parameterfitting/physicalProperties/pureComponentParameterFitting/pureCompViscosity/linearLiquidModel/ViscosityFunction.java
<reponame>equinor/neqsim-parameterfitting<gh_stars>0/*
 * ViscosityFunction.java
 *
 * Created on 24. januar 2001, 23:30
 */

package com.equinor.neqsim.parameterfitting.physicalProperties.pureComponentParameterFitting.pureCompViscosity.linearLiquidModel;

import neqsim.statistics.parameterFitting.nonLinearParameterFitting.LevenbergMarquardtFunction;

/**
 * <p>
 * ViscosityFunction class.
 * </p>
 *
 * @author Even Solbraa
 * @version $Id: $Id
 */
public class ViscosityFunction extends LevenbergMarquardtFunction {
    /**
     * <p>
     * Constructor for ViscosityFunction.
     * </p>
     */
    public ViscosityFunction() {}

    /** {@inheritDoc} */
    @Override
    public double calcValue(double[] dependentValues) {
        system.init(1);
        system.initPhysicalProperties();
        return system.getPhases()[1].getPhysicalProperties().getViscosity() * 1e3;
    }

    /** {@inheritDoc} */
    @Override
    public void setFittingParams(int i, double value) {
        params[i] = value;
        system.getPhases()[0].getComponents()[0].setLiquidViscosityParameter(value, i);
        system.getPhases()[1].getComponents()[0].setLiquidViscosityParameter(value, i);
    }
}
