All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.synerset.hvacengine.fluids.dryair.FlowOfDryAir Maven / Gradle / Ivy

Go to download

HVAC|Engine is a comprehensive library for calculating moist air properties, including crucial thermodynamic processes such as heating, dry cooling, real cooling with condensate discharge, mixing single or multiple air streams, and more. Immutable, thread-safe, very accurate.

There is a newer version: 1.2.0
Show newest version
package com.synerset.hvacengine.fluids.dryair;

import com.synerset.hvacengine.common.Validators;
import com.synerset.hvacengine.fluids.Flow;
import com.synerset.hvacengine.fluids.FlowEquations;
import com.synerset.hvacengine.utils.Defaults;
import com.synerset.unitility.unitsystem.flows.MassFlow;
import com.synerset.unitility.unitsystem.flows.VolumetricFlow;
import com.synerset.unitility.unitsystem.thermodynamic.*;

import java.util.Objects;

/**
 * A class representing the flow of dry air, providing access to various properties of the flow.
 */
public class FlowOfDryAir implements Flow {

    private static final MassFlow MASS_FLOW_MIN_LIMIT = MassFlow.ofKilogramsPerSecond(0);
    private static final MassFlow MASS_FLOW_MAX_LIMIT = MassFlow.ofKilogramsPerSecond(5E9);
    private final DryAir dryAir;
    private final MassFlow massFlow;
    private final VolumetricFlow volFlow;

    /**
     * Construct a `FlowOfDryAir` instance with the specified dry air and mass flow rate.
     *
     * @param dryAir   The dry air associated with the flow.
     * @param massFlow The mass flow rate of dry air in appropriate units.
     */
    public FlowOfDryAir(DryAir dryAir, MassFlow massFlow) {
        Validators.requireNotNull(dryAir);
        Validators.requireNotNull(massFlow);
        Validators.requireBetweenBoundsInclusive(massFlow, MASS_FLOW_MIN_LIMIT, MASS_FLOW_MAX_LIMIT);
        this.dryAir = dryAir;
        this.massFlow = massFlow;
        this.volFlow = FlowEquations.massFlowToVolFlow(dryAir.density(), massFlow);
    }

    @Override
    public DryAir fluid() {
        return dryAir;
    }

    @Override
    public MassFlow massFlow() {
        return massFlow;
    }

    @Override
    public VolumetricFlow volumetricFlow() {
        return volFlow;
    }

    @Override
    public Temperature temperature() {
        return dryAir.temperature();
    }

    @Override
    public Pressure pressure() {
        return dryAir.pressure();
    }

    @Override
    public Density density() {
        return dryAir.density();
    }

    @Override
    public SpecificHeat specificHeat() {
        return dryAir.specificHeat();
    }

    @Override
    public SpecificEnthalpy specificEnthalpy() {
        return dryAir.specificEnthalpy();
    }

    @Override
    public String toFormattedString() {
        return "FlowOfDryAir:\n\t" +
                massFlow.toFormattedString("G", "da", "| ") +
                massFlow.toKiloGramPerHour().toFormattedString("G", "da", "| ") +
                volFlow.toFormattedString("V", "da", "| ") +
                volFlow.toCubicMetersPerHour().toFormattedString("V", "da") +
                "\n\t" +
                dryAir.toFormattedString() +
                "\n";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FlowOfDryAir that = (FlowOfDryAir) o;
        return Objects.equals(dryAir, that.dryAir) && Objects.equals(massFlow, that.massFlow);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dryAir, massFlow);
    }

    @Override
    public String toString() {
        return "FlowOfDryAir{" +
                "dryAir=" + dryAir +
                ", massFlow=" + massFlow +
                ", volFlow=" + volFlow +
                '}';
    }

    // Class factory methods
    // Class factory methods

    /**
     * Create a new `FlowOfDryAir` instance with the specified mass flow rate.
     *
     * @param massFlow The mass flow rate of dry air in appropriate units.
     * @return A new `FlowOfDryAir` instance.
     */
    public FlowOfDryAir withMassFlow(MassFlow massFlow) {
        return FlowOfDryAir.of(dryAir, massFlow);
    }

    /**
     * Create a new `FlowOfDryAir` instance with the specified volumetric flow rate.
     *
     * @param volFlow The volumetric flow rate of dry air in appropriate units.
     * @return A new `FlowOfDryAir` instance.
     */
    public FlowOfDryAir withVolFlow(VolumetricFlow volFlow) {
        return FlowOfDryAir.of(dryAir, volFlow);
    }

    /**
     * Create a new `FlowOfDryAir` instance with the specified dry air.
     *
     * @param dryAir The dry air associated with the flow.
     * @return A new `FlowOfDryAir` instance.
     */
    public FlowOfDryAir withHumidAir(DryAir dryAir) {
        return FlowOfDryAir.of(dryAir, massFlow);
    }

    // Static factory methods

    /**
     * Create a new `FlowOfDryAir` instance with the specified dry air and mass flow rate.
     *
     * @param dryAir   The dry air associated with the flow.
     * @param massFlow The mass flow rate of dry air in appropriate units.
     * @return A new `FlowOfDryAir` instance.
     */
    public static FlowOfDryAir of(DryAir dryAir, MassFlow massFlow) {
        return new FlowOfDryAir(dryAir, massFlow);
    }

    /**
     * Create a new `FlowOfDryAir` instance with the specified dry air and volumetric flow rate.
     *
     * @param dryAir  The dry air associated with the flow.
     * @param volFlow The volumetric flow rate of dry air in appropriate units.
     * @return A new `FlowOfDryAir` instance.
     */
    public static FlowOfDryAir of(DryAir dryAir, VolumetricFlow volFlow) {
        Validators.requireNotNull(volFlow);
        MassFlow massFlow = FlowEquations.volFlowToMassFlow(dryAir.density(), volFlow);
        return new FlowOfDryAir(dryAir, massFlow);
    }

    /**
     * Create a new `FlowOfDryAir` instance with specified absolute pressure, temperature, and volumetric flow rate.
     *
     * @param absPressure The absolute pressure of dry air in pascals (Pa).
     * @param temperature The temperature of dry air in degrees Celsius (°C).
     * @param m3hVolFlow  The volumetric flow rate of dry air in cubic meters per hour (m³/h).
     * @return A new `FlowOfDryAir` instance.
     */
    public static FlowOfDryAir ofValues(double absPressure, double temperature, double m3hVolFlow) {
        Pressure absPress = Pressure.ofPascal(absPressure);
        Temperature temp = Temperature.ofCelsius(temperature);
        VolumetricFlow volFlow = VolumetricFlow.ofCubicMetersPerHour(m3hVolFlow);
        DryAir dryAir = DryAir.of(absPress, temp);
        return of(dryAir, volFlow);
    }

    /**
     * Create a new `FlowOfDryAir` instance with specified temperature and volumetric flow rate at standard atmosphere pressure.
     *
     * @param temperature The temperature of dry air in degrees Celsius (°C).
     * @param m3hVolFlow  The volumetric flow rate of dry air in cubic meters per hour (m³/h).
     * @return A new `FlowOfDryAir` instance.
     */
    public static FlowOfDryAir ofValues(double temperature, double m3hVolFlow) {
        double pressure = Defaults.STANDARD_ATMOSPHERE.getInPascals();
        return ofValues(pressure, temperature, m3hVolFlow);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy