carbatpy.models.cb_fluids.fluid_props ===================================== .. py:module:: carbatpy.models.cb_fluids.fluid_props .. autoapi-nested-parse:: Created on Mon May 22 21:09:12 2023 @author: atakan Attributes ---------- .. autoapisummary:: carbatpy.models.cb_fluids.fluid_props.VERBOSE carbatpy.models.cb_fluids.fluid_props.DEFAULTS carbatpy.models.cb_fluids.fluid_props.TREND carbatpy.models.cb_fluids.fluid_props.FLUID Classes ------- .. autoapisummary:: carbatpy.models.cb_fluids.fluid_props.FluidModelDefaults carbatpy.models.cb_fluids.fluid_props.FluidModel carbatpy.models.cb_fluids.fluid_props.FluidState carbatpy.models.cb_fluids.fluid_props.Fluid Functions --------- .. autoapisummary:: carbatpy.models.cb_fluids.fluid_props.init_fluid Module Contents --------------- .. py:data:: VERBOSE :value: False .. py:data:: DEFAULTS .. py:data:: TREND .. py:class:: FluidModelDefaults .. py:attribute:: units :value: 21 .. py:attribute:: props :value: 'REFPROP' .. py:attribute:: rp_inst :value: False .. py:attribute:: eos_ind :type: Optional[List[int]] :value: None .. py:attribute:: eos_ind_default :type: int :value: 1 .. py:attribute:: mix_ind :value: 1 .. py:attribute:: trendmodel :value: '' .. py:attribute:: path :value: '' .. py:attribute:: dll_path :value: '' .. py:attribute:: props_func :value: None .. py:class:: FluidModel(fluid, composition=[1], **kwargs) Fluid model to be used Refprop or TREND Only model, chemical compunds units and for TREND some more values are set here. The mixture composition, state etc. is set in Fluid. For Class Fluidmodell a fluid (mixture) must be defined, the evaluation takes place with props, units can be set and an instance can be set, the latter is important, if more than one fluid is used. For Refprop: Initiates new instance for each fluid (mixture). :param fluid: as defined in the props (Model), for RefProp it is "fluid1 * fluid2 * fluid3". :type fluid: String :param composition: of working fluid (mixture), at this level only used for TREND :type composition: array :param \*\*kwargs: units, props, rp_inst, eos_ind, mix_ind, trendmodel, props_func (see dataclass FluidModelDefaults). For props="CUSTOM", props_func must be a callable with signature:: func(values, given) -> list[T, P, H, V, S, Q, U, ...] returning SI values (K, Pa, J/kg, m³/kg, J/kg/K, -, J/kg). :type \*\*kwargs: dict :rtype: None. .. py:attribute:: fluid .. py:attribute:: props :value: 'REFPROP' .. py:attribute:: units :value: 21 .. py:method:: fluid_to_list() Converts the fluid names string from Refprop to a list for TREND :returns: the fluid names in a list. :rtype: List of strings .. py:class:: FluidState(state, what, **kwargs) The thermodynamic state of a fluid is stored here. Which properties (T,p,h,v,s,q,...), depends on: carbatpy.CB_DEFAULTS["Fluid_Defaults"]["Property_Names_Short"] .. py:attribute:: props .. py:attribute:: verbose .. py:attribute:: liq_x .. py:attribute:: vap_y .. py:attribute:: total_z .. py:attribute:: state .. py:method:: state_to_dict() Convert the state properties to a dictionary name:value. .. py:class:: Fluid(fluidmodel, composition=None, option=1) The Fluid class is used to set, get, and print states of a fluid with a given model (e.g. RefProp). The compounds are set in the fluidmodel, while the composition is also set here. The calculated values depend also on carbatpy.CB_DEFAULTS["Fluid_Defaults"]["Property_Names_Short"]. Generate a Fluid instance a FluidModel instance, the composition and an unused option has to be passed. :param fluidmodel: the instance of the property model to be used. :type fluidmodel: FluidModel :param composition: mole fractions of all compounds. The default is [1.0]. :type composition: list, optional :param option: unused. The default is 1. :type option: TYPE, optional :rtype: None. .. py:attribute:: fluidmodel .. py:attribute:: composition .. py:attribute:: properties :value: None .. py:attribute:: state_v :value: None .. py:attribute:: option :value: 1 .. py:attribute:: no_compounds .. py:attribute:: comp_mass .. py:attribute:: herr :value: 0 .. py:attribute:: props .. py:attribute:: val_dict .. py:method:: set_composition(composition, **kwargs) Mole fractions are set and mass fractions are calculated. Sets the self.composition used in the Fluid settings and the self.comp_mass TREND needs the mass fractions for specific (/kg) calculations. Thus calc_mass_fraction() is called. :param composition: mole fractions must sum up to 1. :type composition: list/numpy.array :param kwargs: - verbose : boolean, optional. Generate additional printig. The default is False. :type kwargs: dictionary, optional. :rtype: None. .. py:method:: calc_mass_fraction() mole to mass fractions for TREND .. py:method:: calc_mole_fraction(comp_mass) needed for x_liq and y_vap in TREND, therefore mass fraction passed as function argument. .. py:method:: set_state(values, given='TP', wanted=_THERMO_STRING, composition=None, **kwargs) Sets the state of a fluid and calculates the wanted properties. :param values: the two state parameter values. :type values: list[2] :param given: What are the two values (T,P,H,S,Q,V). The default is "TP". :type given: String, optional :param wanted: Which parameters shall be calculated? The default is _THERMO_STRING. :type wanted: String, optional :param composition: mole fraction of each compound, must sum up to 1. When empty, the last/actual value will be used. The default is []. :type composition: list, optional :param kwargs: dll_select : str, optional is passed to Refprop. The standard value is "2dll" using the faster REFPROP2dll function, not calculating the composition of different phases. The alternative "dll" is slower but does it. Throughout it is expected that compoitions are mole fractions and qualities in mass/mass. i_mass : int (0/1), optional should not be used, not tested. i_flag : int (0/1), optional should not be used, not tested. verbose : Boolean, optional leads to additional (printing) output. The default value is False. output : String, optional what shall be the return value, the "state" as list or an instance of the "FluidState". default is "state" :type kwargs: dictionary, optional :raises Exception: DESCRIPTION. :returns: DESCRIPTION. :rtype: TYPE .. py:method:: calc_q_mass(q, liq_x, liq_y) .. py:method:: set_state_v(values, given='TP', wanted=_THERMO_STRING, **kwargs) set many Fluid states with the values given as array(vector) :param values: the N value pairs to fix the states. :type values: numpy.array((N,2)) :param given: what are the input values?(T,P, Q, S,...). The default is "TP". :type given: String, optional :param wanted: with all the outputs wanted. The default is _THERMO_STRING. :type wanted: String, optional :param kwargs: This is optional and passed to REFPROP or TREND, depending on the props settings / chosen property model. (see set_state()) :type kwargs: dictionary optional :returns: **output** -- all the wanted properties for the N inputs. :rtype: numpy.array(N, n_wanted) .. py:method:: print_state() Print the actual state of the Fluid .. py:method:: calc_temp_mean(h_final) Calculate the thermodynamic mean temperature between the actual state and the final enthalpy along an isobaric (Delta h /Delta s) :param h_final: enthalpy of he final stat. :type h_final: float :returns: **temp_mean** -- the thermodynamic mean temperature. :rtype: float .. py:function:: init_fluid(fluid, composition, **keywords) short way to define a Fluid and a FluidModel :param fluid: The species within the fluid. :type fluid: string :param composition: mole fraction for each fluid. :type composition: List :param \*\*keywords: all keywords needed for the FluidModel, if non-defaults shall be set. :type \*\*keywords: TYPE :returns: **actual_fluid** -- Instance of the actually set Fluid. :rtype: Fluid .. py:data:: FLUID :value: 'Propane * Pentane'