Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

UDF for definining saturation temperature as a function of pressure

    • Ajayc1160
      Subscriber

      Hello


      I am trying to simulate a bulk condensation phenomena where vapor condenses to liquid when it reaches below saturation temperature. I am trying to do this using evaporation/condensation model in ansys fluent. Is this correct ?


      Also I am trying to define the saturation temperature in Lee condensation model with following UDF

      Is the following UDF correct?


      #include "udf.h"

      #define h2o 0

      DEFINE_PROPERTY(sattemprev,c,t)

      {

      real sat_t;

      real abs_p;

      real vapor_p;

      real mf_vapor =C_YI(c,t,0) ;

      real static_p = C_P(c,t);

      real operating_p = RP_Get_Real ("operating-pressure");

      abs_p = static_p + operating_p;

      vapor_p = mf_vapor * abs_p;

      sat_t = ((243.04*((double)log10((double)vapor_p/0.61094)))/(17.625-((double)log10((double)vapor_p/0.61094))))+273.15;

      return sat_t;

      }

    • Rob
      Forum Moderator
      What happens when you compile & hook it up? If you attach the sat_t to a UDM do you get the values you expect when patching in different temperature & pressure?
    • Ajayc1160
      Subscriber
      It successfully compiles without any errors

      When I initialize or run , I get 99999 mpt error: file or directory not found and fluent crashes out before I can view mor details in the console about the error

      Is the above udf written properly for fluent while running it on parallel?
    • Rob
      Forum Moderator
      Have a look in the working folder for the log files, if there's not one start a transcript (File-Write) as that'll record what is in the TUI as the solver fails.
    • Ajayc1160
      Subscriber
      Ok. How do i write in the the file to record the content in TUI? Do you have any examples?
    • Rob
      Forum Moderator
      File-Write-Transcript it's in the menu system. If it's not in Write check Export.
    • Ajayc1160
      Subscriber
      Hello Rob the problem has been solved but I get a new error now
      I get this error while trying to initialize the saturation temperature
      Following is the saturation temp udf i used

      #include "udf.h"
      #define h2o 0
      DEFINE_PROPERTY(sattemprev,c,t)
      {
      real sat_t;
      real abs_p;
      real vapor_p;
      real mf_vapor =C_YI(c,t,0) ;
      real static_p = C_P(c,t);
      real operating_p = RP_Get_Real ("operating-pressure");
      abs_p = static_p + operating_p;
      vapor_p = mf_vapor * abs_p;
      if (mf_vapor=0)
      sat_t = 333;
      else
      sat_t = ((243.04*((double)log10((double)vapor_p/0.61094)))/(17.625-((double)log10((double)vapor_p/0.61094))))+273.15;
      return sat_t;
      }

      Any idea whats the casuing the issue?
    • Ajayc1160
      Subscriber
      So what I am trying to do here is set the saturation temperature of vapor species (h20) as a function of its mass fraction and absolute pressure. In my cfd model , I have vapor and air defined in a mixture as a species . The other phase is only water. I am trying to simulate the condensation of humid air in a vertical channel
    • Rob
      Forum Moderator
      It looks like there's no check on sat_t so if the equation gives a nonsense result (eg sat_t < 0 K) it'll add that into the solver.
    • Amine Ben Hadj Ali
      Ansys Employee
      I do not debug UDF's here but your specie mass fraction is not property of the mixture but rather of a phase. You need to correct that too.
    • Ajayc1160
      Subscriber
      Hi Rob
      Thanks for letting me know. So how do I define a check for saturation temperature when I am determining it as a function of pressure? Also I tried initializing the domain with mass fraction value of h20 as 1 and absolute pressure as 10KPa Hence there is no possibility of sat_t becoming less than 0 anywhere in the domain. I dont understand from where the solver calculates this value.


    • Ajayc1160
      Subscriber
      Hi Dr Amine

      What do you mean? Do you mean to say that I need to correct the expression real mf_vapor =C_YI(c,t,0) ; to account for a phase instead of a mixture ? In my model I have defined h20 as a phase in a mixture of air and h20 through species transport model. So I dont exactly understand what you meant
    • Amine Ben Hadj Ali
      Ansys Employee
      Yes what you defining is wrong. You need to read the Customization manual and get acquainted to the multiphase multi-threading. Mass Fraction is defined as Phase Property so the passed cell thread should be the phase level cell thread and mixture level thread.
    • Ajayc1160
      Subscriber
      Could you let me know which example I should follow in ANSYS Fluent manual? There are so many examples involving mixtures and phases
    • Ajayc1160
      Subscriber
      Also I wanted to ask if I add a non condensable gas like air into the mixture, should I change the code for condensation UDF to define non condensable gas of air ? Air does nothing much in the system. Its just to account for resistance of condensation due to non condensable gas
    • Rob
      Forum Moderator
      You need to adjust your UDF to account for whatever it is you're trying to model. Read all of the examples, you're probably going to need elements of some/most/all of them.
    • Ajayc1160
      Subscriber
      Hi Rob .
      Now I am really confused. I did look at the examples in the UDF. There are a total of 3 examples where condensation is used but very little information is given in the udf as to what each command line does in each stage or in some examples, the equation is not clear. Could you please help me out to understand this ?
    • Ajayc1160
      Subscriber
      I would be more than happy if you could explain the logic with which I should proceed. So in my domain, there will be a species transport mixture of water vapor and air, while another phase is liquid.
    • Rob
      Forum Moderator
      Very roughly, you need to work out what the phase change mechanism is (ie rate of change is based on something) and then move mass from one phase (and species) to the other phase (and species). It's not necessarily simple,
    • Ajayc1160
      Subscriber
      I am aware about that . What I am asking is how to define this in UDF. I dont have much experience in writing UDFs. The phase change is dependent on saturation vapor pressure . I just want one species to be present and have the phase change from gas to liquid phase . Could you give me a brief overview of how this should be done?

      Also how do I define the saturation vapor pressure as function of pressure ? I am aware that there are multiple equations like Anotinne equation to calculate this but I cant follow what method was used in example UDFs(ANSYS Customization manual) to obtain the saturation pressure as function of temperature
    • Ajayc1160
      Subscriber
      Here is what I am planning to do . I am planning to define mass transfer UDF with saturation pressure as limiting condition . Saturation pressure is defined as a function of temperature in the domain . Is this the correct way to go ? I have two species mixtures - one will be mixture of air and vapor. Other is liquid alone.
      Which physics should I choose for phase transfer? Is it Eulerian mixture model or VOF model?
    • Ajayc1160
      Subscriber
      One more question I had is if I define a user defined source term (removal flux of vapor as rate of condensation) on a wall for species equation, is the pressure change caused by adding this source term accounted for in momentum equation and continuity equation automatically by fluent or should I add them manually?
    • Amine Ben Hadj Ali
      Ansys Employee
      If it's free surface phase change then you can go with VOF model and use compressive scheme. If well mixed then mixture model might be enough. You can look into define mass transfer to write your own mass transfer law.
Viewing 22 reply threads
  • The topic ‘UDF for definining saturation temperature as a function of pressure’ is closed to new replies.