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

Non-Newtonian Media

Non-Newtonian Media

Dear Modelica team,

I am looking to find a 'non-Newtonian' Media / fluid to use in my simulation. I am very much an entry level user and while reading up about the fluids, methods, ways I do not think that I would be able to create this myself.

I have seen various posts, in which companies / developers have programmed 'non-Newtonian fluid; in Modelica, but I belief that the created packages are likely proprietary.

https://2018.american.conference.modeli … ons_26.pdf

Any advise, direction or help is highly appreciated.

many thanks,
Tom

Re: Non-Newtonian Media

Hi Tom,
I would say that the difficulty of the solution depends mainly in the possibility, or not, of using a pure substance medium. In a pure substance medium thermodynamic properties are independent of composition or, in other words, composition is fixed.
If you can use a pure substance medium, you can extend from, for example, Modelicas's standard library PartialSimpleMedium, or PartialLinearFluid. Or if you need a more sophisticated calculation, you can use other opensource libraries. In this situation your main work will be writting the dynamicViscosity function. All the media functions are expected to receive as input only a ThermodynamicState record, but in your case the viscosity depends not only on the thermodynamic state but also in the shear strain rate. Nevertheless this doesn't seem a strong limitation: when you extend the partial function dynamicViscosity, you can add as input the shear strain rate, and make the calculation taking it into account.
If you need a medium with properties dependence on composition, as it seems is the Modelon's drilling library case (brine+base oil) , situation is much more complex. As far as I know there is no opensource package covering this for liquids. I have in my plans to develope one using PCSAFT EOS for thermodynamic properties calculation and residual entropy for transport properties, but I will need some months for this. Nevertheless, if you are going to write a media package and need some support, I will try to help.

Regards

Carlos

Re: Non-Newtonian Media

Hi Carlos,

thanks for the excellent explanation. I think that utilizing a pure substance might not be a bad idea and might get me closer. I assume that I need to figure out the 'modification' of the dynamicViscosity function to add the shear rate, which would need to be done.
In addition, I think I would have to chose a pure substance that allows me to start with 'higher' density fluid. Assuming I would have to change / update MolarMass and / or the reference density.
many thanks,

Re: Non-Newtonian Media

Yes, you can begin with a pure substance and Modelica.Media.Interfaces.PartialLinearFluid seems a good start base. It uses constant isobaric expansion coefficient (beta) and isothermal compressibility (kappa). reference_d, reference_h and reference_s are just the values of density, enthalpy and entropy at reference temperature and pressure. Of course you can assign to reference_h and reference_s any value. The variation in enthalpy and entropy is calculated using a constant Cp and considering that internal energy doesn't depend on pressure. The molecular mass has no influence in the calculation, that is always done in mass units, no in mole units (Cp is in J/(kg·K)).
It follows an example using a power law for viscosity calculation:

package LinearNNMedium "Linear medium with non-Newtonian viscosity"
  extends Modelica.Media.Interfaces.PartialLinearFluid(
    mediumName="Linear medium",
    constantJacobian=true,
    reference_p=101325,
    reference_T=278.15,
    reference_d=900,
    reference_h=0,
    reference_s=0,
    cp_const=3200,
    beta_const=2.5713e-4,
    kappa_const=4.5154e-10,
    MM_const=0.1);

  redeclare function extends dynamicViscosity
    input Real ssr=0 "shear strain rate";
  protected
    DynamicViscosity eta0=0.1 "viscosity at 0 shear strain rate";
    DynamicViscosity etaInf=0.001 "viscosity at infinite shear strain rate";
    Real n=0.5 "flow behavior index";
  algorithm
    eta := if ssr>0 then  etaInf+(eta0-etaInf)*ssr^(n-1.0) else eta0;
  end dynamicViscosity;

  redeclare function extends thermalConductivity
  algorithm
    lambda := 0.572;
  end thermalConductivity;
end LinearNNMedium;

model NNMediumExample
  package Medium=LinearNNMedium;
  parameter Medium.Temperature T=300;
  parameter Medium.AbsolutePressure p=2e5;
  parameter Real ssr=100;
  Medium.ThermodynamicState state;
  Medium.DynamicViscosity eta;
equation
  state=Medium.setState_pTX(p,T);
  eta=Medium.dynamicViscosity(state,ssr);
end NNMediumExample;

The problem you will find when using this type of medium with Modelica.Fluid is that Modelica.Fluid is not prepared for a non-standard medium like this one. When it needs the viscosity it will call the dynamicViscosity function giving just the thermodynamic state and in plus, as far as I know, Modelica.Fluid has no support for shear strain rate consideration. I think that you have here two options: one is to write your own flow models. The second is to define different medium models fixing the shear strain rate at the required value and later calling the needed one.

Re: Non-Newtonian Media

Thanks Carlos,

I will try to get started with the Linear Medium, following your guidance. Got to get use to h, s, etc. See about density, etc.

Thanks !

Re: Non-Newtonian Media

Hey Carlos,

The below listed do actually, or go into my model? Will this work and not cause any issues? Thought I need to define these in the package..

  parameter Medium.Temperature T=300;
  parameter Medium.AbsolutePressure p=2e5;
  parameter Real ssr=100;
  Medium.ThermodynamicState state;
  Medium.DynamicViscosity eta;
equation
  state=Medium.setState_pTX(p,T);
  eta=Medium.dynamicViscosity(state,ssr);

Re: Non-Newtonian Media

All the code inside the model NNMediumExample is just an example of how the package can be used to get the viscosity. You must write your medium package assigning value to the constants according to your substance. Later you can use this medium package inside your models to get the thermodynamic and transport properties needed.

Re: Non-Newtonian Media

Got it. Sort of figured it out along the way. Just a little slow on catching on.

many thanks,

There are 0 guests and 0 other users also viewing this topic