Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

for loop error

for loop error

           Hello all,

            I will appreciate the help to resolve following error.
            I have wrote a code using 'for loop' but getting an error as " Basic type inconsistencies detected" while I perform the check.
            I can share some part of code which is as follows

            replaceable package Medium = ThermoFluidPro.Media.Technical.IsoButane constrainedby
                ThermoFluidPro.Media.Interfaces.ExtendedPartialTwoPhaseMedium
                "Medium in the component"
                  annotation(editButton=false,choicesAllMatching,
                Documentation(revisions="<html>
                       .....
                       .....
              for N in 1:N loop
                       ....
                        ....
                      state[N]=Medium.setState_pTX(Sat_P1[N],Tct[N]);
                       Ktp_ct[N]=Medium.thermalConductivity_dTX(state[N].d, state[N].T,state[N].X);
                         ....
                      Cpf_ct[N]=Medium.specificHeatCapacityCp_dTX(d=Rho_tp[N],T=Tct[N],X=Medium.fixedComposition,phase=0);
                     state1[N]=Medium.setState_pTX(Ps_in,Tsl[N]);
                      mug_sl[N]= Medium.dynamicViscosity(state1[N]);
            end for;

            Is there any problem in medium declaration or functions that are used for variable values?

            Thank you.

Edited by: MSJ - Jul-30-19 03:51:36

Re: for loop error

Edited,

My suggestion failed

Edited by: didrif14 - Jul-30-19 06:39:10

Re: for loop error

Hi,
I know nothing about the ThermoFluidPro library, so I will try to comment the code according to my knowledge of Modelica.Media.
I understand that you are selecting a monocomponent medium (isobutane) for a two phases application. If the library is fully compliant with Modelica PartialTwoPhaseMedia, the following comments could apply.
You have an array of states that you are creating from an array of pressures, and an array of temperatures . As you are not supplying composition, I understand that the medium has a fixed composition. My first point is a question. Does the array of pressures correspond to the saturated pressures of the array of temperatures?  My question is due to the name of the array of pressures, and to the fact that a state can´t be constructed by the setState_pTX function if the supplied values correspond to a saturated condition.
You are using the setState_pTX function to build the state. I would say that you should use setState_pT, as there is no specific composition to pass, but this should not be a problem, because if you do not specify the composition the function should use reference_X.
When recovering the thermal conductivity you are using  thermalConductivity_dTX, and passing density, temperature and composition of the previously created state. This seems to mean that composition is a variable inside the ThermodynamicState record. Why don’t you just use thermalConductivity(state[N]). In the way you do, if it works, you will normally create a new state just for the calculation of the thermal conductivity.

Carlos

There are 0 guests and 0 other users also viewing this topic
You are here: