Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Specific heat UDF energy imbalance

    • Anagh Dave
      Subscriber

      Hi everyone , 

      I am  trying to tackle an issue with energy imbalance when I use the specific heat UDF as specified . There doesnt seem to be many issues when I have low eneough Re . However when I enter a region near 1000 inlet Re , the energy imbalance pops up and the continuity residual doesnt go below 1e-5 . I changed the properties of the material in the UDF , however nothing really worked .

      I would very much appreciate any help I could get . 

    • Rob
      Forum Moderator

      There's nothing in the code snippet that's linked to the flow variables so what changes in the flow field in that area other than it's a bit more turbulent? I'm also assuming you've got the rest of the code in the UDF, ie the main macro etc. 

    • Anagh Dave
      Subscriber

      As you can see, there are turbulators on the channel floor which causes mixing . 

    • Rob
      Forum Moderator

      Is the problem that at higher flows you don't get convergence, or that in regions with higher turbulence you don't think energy is converged? 

    • Anagh Dave
      Subscriber

      Umm so just to elaborate, what I did was just apply a flow velocity at the inlet corresponding to Re range from 100 to 1000. Then I just checked to make sure at every velocity for the energy balance through the fluxes tab . The energy residual is always in 1e-7s. It's the continuity residual that does not go down or converge, it flattens out at 1e-5 or relatively earlier to energy. 

    • Rob
      Forum Moderator

      OK, continuity tends not so coverge as far, check the monitors tab for the default values of residual at convergence. 

      As flow increases you may find separation can occur on your turbulators, which may not help convergence. Have a look at the laminar/turbulent lectures in Learning. 

    • Anagh Dave
      Subscriber

      Ok , so over all there is turbulence even at lower Reynolds numbers, hence I am not too sure if the boundary layer seperation is the issue. Secondly , I have set everything to 1e-6 

    • Anagh Dave
      Subscriber

      I have tried changing the properties and it still is an issue.  Could anyone help me around ? I think it may be the format of the Specific heat file? 

    • Rob
      Forum Moderator

      You can get laminar separation too. If you manually calculate the various values for cp & h* what do you see? By all means use a UDF to alter properties, but why make the solver calculate the value for every cell when it's a constant? 

    • Anagh Dave
      Subscriber

      So the specific heat varies with temperature and it increases up to some higher amount for a small range of temperature which I am interested in seeing . The change occurs as a complex function of temperature (which varies with distance across the channel).

    • Rob
      Forum Moderator

      Except in your case it has 3 values based on three temperature ranges. How sudden a jump in value is there?

    • Anagh Dave
      Subscriber

      It's a large change , and it's gradual . Historically even in literature or research papers , authors have used a UDF to initiate this transition or program the transition of the specific heat 

    • Rob
      Forum Moderator

      That's not gradual, you have three fixed constant values for three temperature ranges. 

      T

      T = constant cp

      T>Tl = constant cp

      As none of the terms in the cp equations are variables. 

       

    • Anagh Dave
      Subscriber

      Actually the CP value changes with temperature or as a sine curve . The CP is not constant in the middle range 

    • Rob
      Forum Moderator

      That's not what is set in your UDF. 

    • Rob
      Forum Moderator

      Actually, I was wrong, you only have one cp value set using the UDF. 

    • Anagh Dave
      Subscriber

      cp = (1-phi)*cp_w + phi*(cp_p + (M_PI/2*(lambda/Mr-cp_p))*sin(M_PI*((T-Ts)/Mr)));

      *h=  (phi*(cp_p)+ (1-phi)*(cp_w))*(Ts-Tref)+(1-phi)*cp_w*(T-Ts) +phi*cp_p*(T-Ts) +phi*(M_PI/2*(lambda/Mr-cp_p))*(Mr/M_PI)*(-(cos(M_PI*((T-Ts)/Mr)) - 1)); 

      As you can see , in this part of the UDF , The cp value changes with T , every other part of it is constant .

    • Rob
      Forum Moderator

      Where is T defined?

    • Anagh Dave
      Subscriber

      T is the Temperature taken from the simulation right? T is the varying temperature inside the channel .

    • Rob
      Forum Moderator

      Sorry, yes, it's usually pulled from C_T(c,t) rather than passed to the macro. 

    • Anagh Dave
      Subscriber

      #include "udf.h"

      DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)


      {  

      double cp;
      double cp_p = 3260;
      double cp_w = 4182;
      double phi=0.147096431;
      double Ts=305;
      double Tl=308;
      double lambda=251000;
      double Mr=Tl-Ts;

      if (T<=Ts)


      {


      cp = phi*(cp_p)+ (1-phi)*(cp_w);

      *h = cp*(T-Tref);
      }

      else if (T>=Tl)


      {

      cp = phi*(cp_p)+ (1-phi)*(cp_w);
      *h=(phi*(cp_p)+ (1-phi)*(cp_w))*(Ts-Tref)+(1-phi)*cp_w*(Tl-Ts) +phi*cp_p*(Tl-Ts) +phi*(M_PI/2*(lambda/Mr-cp_p))*(Mr/M_PI)*(-(cos(M_PI*((Tl-Ts)/Mr)) - 1)) + (phi*(cp_p)+ (1-phi)*(cp_w))*(T-Tl);

      }

      else 


      {


      cp = (1-phi)*cp_w + phi*(cp_p + (M_PI/2*(lambda/Mr-cp_p))*sin(M_PI*((T-Ts)/Mr)));

      *h=  (phi*(cp_p)+ (1-phi)*(cp_w))*(Ts-Tref)+(1-phi)*cp_w*(T-Ts) +phi*cp_p*(T-Ts) +phi*(M_PI/2*(lambda/Mr-cp_p))*(Mr/M_PI)*(-(cos(M_PI*((T-Ts)/Mr)) - 1));
      }

       

       

       


      return cp;


       

      This is how I have defined my UDF 

    • Rob
      Forum Moderator

      And if you plot contours of cp, do the values look smooth and do they agree with what you're expecting? 

    • Anagh Dave
      Subscriber

      They agree to the specified  UDF 

    • Rob
      Forum Moderator

      And values are smooth with well refined gradients? How is the flow over the turbulators? 

    • Anagh Dave
      Subscriber

      Temperature and Velocity gradients seem smooth (turbulence wise) . The cp varies as followed, it spikes up at a given distance as the the temperature increases and then decreases gradually. However for higher velocities , it spikes up and remains at that specific heat all the way to the outlet. 

    • Anagh Dave
      Subscriber

    • Rob
      Forum Moderator

      Does the higher velocity cause separation on the turbulators? Zoom in and look at the velocity vectors. 

    • Anagh Dave
      Subscriber

      So the continuity residual does not converge. There is a large turbulence in the system, with vortices spreading longitudinally. I believe this energy imbalance behavior may be related to the increased Cp. However I have noticed that this occurs only for higher velocities . However, the flow behavior doesn't seem so different from lower velocities 

    • Rob
      Forum Moderator

      Plot the full range of cp out using the equations in the UDF. Now look at the temperature field in your model. If you're seeing separation, are you getting hot spots on the lee of the fins? 

    • Anagh Dave
      Subscriber

    • Anagh Dave
      Subscriber

      As you can see , there is still an imbalance 

    • Rob
      Forum Moderator

      2%, so not too bad. How are the near wall mesh, convergence and overall monitor behaviour? 

    • Anagh Dave
      Subscriber

      I think it is a mesh issue. Currently, I have no inflation layers or any ways to resolve boundary layers. I have tried to including inflation layers, but I haven't been able to do that without reducing the quality of the mesh 

    • Rob
      Forum Moderator

      Inflation onto ribs won't be that straightforward. Don't forget to refine in the streamwise direction around the fins too: high aspect ratio cells and separation are not a good combination. 

    • Anagh Dave
      Subscriber

      The residuals just flatten out before it reach a good enough convergence of 1e-6 for continuity if I use refinement .

    • Rob
      Forum Moderator

      That should be sufficient, general guidance is 1e-6 for energy, 1e-5 for species and 1e-3 for the rest; that should be covered in the training in Learning. 

    • Anagh Dave
      Subscriber

      Would it be possible to automate this UDF? i.e make the phi as a variable

    • Rob
      Forum Moderator

      As in change phi from the GUI? Possible yes; easy, not so much. You're needing to promote values as parameters into Fluent or using Scheme & GUI coding; the former is in the UDF manual, the latter is in the other half of the customisation manual: I don't recommend either unless you're experienced and doing a lot of runs. 

    • Anagh Dave
      Subscriber

      Yeah , I do need to do multiple runs in which I change the parameter and also some geometric parameters 

    • Anagh Dave
      Subscriber

      I am still having an issue with the specific heat and temperature profiles. They seem to be very irregular in nature.In other words, I believe a boundary layer mesh may be necessary. If you notice the fluctuation of cp behind the ridges 

    • Rob
      Forum Moderator

      Possibly, and you'll also need to resolve along the wall too. 

    • Anagh Dave
      Subscriber

    • Anagh Dave
      Subscriber

    • Anagh Dave
      Subscriber

      I tried to bias the edges of the ridges or the channel edges , but none of those options worked to form a clean boundary layer mesh 

    • Rob
      Forum Moderator

      There's a pale blue triangle on the clip plane panel, that shows the full cell rather than slicing through it. If you zoom in on 2-3 fins it'll be easier to see too. 

    • Anagh Dave
      Subscriber

      Do you mean something like this ?

       

    • Anagh Dave
      Subscriber

      I would like some kind of hexahedral mesh or a controllable tetrahedral mesh for the free mesh in the domain ideally.

    • Rob
      Forum Moderator

      Yes, and now press the blue triangle icon. A hex mesh may be better (note, may, as opposed to will) and have a look at boundary adaption as that may be a more efficient way to resolve the near wall mesh. 

    • Anagh Dave
      Subscriber

       

       

      Hi , I think I have solved the mesh issue now . However ,I just had a question about running the mass fraction parameter.  So I executed the commands as specified in the document  and it runs perfectly if I have the fluent window open and just change the parameter value in the workbench. However , it fails to initialise while running in automation unsupervised. Right when it switches to the next design points and undergoes setup changes . I get the error in the solution monitor as ‘ unable to find rpvar’. I have been looking at some solutions however , I havent found one suitable.  To expand on this , the simulation will run once I initialise it and if I need to run it again , it fails with the same error .  All I have done is parameterise the mass fraction using rp var define command and use the lambda script procedure to assign the value . I have only followed the steps given here https://www.computationalfluiddynamics.com.au/how-can-i-drive-fluent-udf-parameters-directly-from-ansys-workbench/ 

       

       

    • Rob
      Forum Moderator

      LEAP are always very good at publishing solutions - good find. 

    • Anagh Dave
      Subscriber

      Yes , but it didn't work as you can see. I was wondering if you could provide some insight on this 

    • Rob
      Forum Moderator

      Messing with rpvar's isn't generally supported. As mentioned you may want to review setting up models and running sequentially and not use parameters. 

    • Anagh Dave
      Subscriber

       

      That would actually take up a lot of time , for the number of simulations I need to conduct .  Would it be possible to use some other technique to help the process? 

       

    • Rob
      Forum Moderator

      How many of what changes are needed? Your other option is potentially Optislang but that's not something I know much about. 

    • Anagh Dave
      Subscriber

       

      Well I have four parameters sampled through Latin Hypercube Sampling(about 50 data runs).  These parameters include geometrical (which are followed by some mesh parameters for example no. of divisions ) , velocity and the mass fraction variable 

       

    • Rob
      Forum Moderator

      You may want to look at sets where the UDF is set. That also allows you to run some sets simulataneously. Otherwise Optislang may be your best option. 

      Replacing the UDF with an Expression looked vaguely possible but that seems limited to IF ELSE and not IF IF ELSE. Maybe in the future. 

    • Anagh Dave
      Subscriber

       

      I am not sure if OptiSlang would be the best option , because I am changing the mesh according to the geometrical change . i.e to maintain some element quality and skewness. Therefore some mesh independence as well .

      So just to cover  the process . every single time I change the geometrical parameters , and initialise the fluent file , the variable fails to do so . However if I dont change anything outside the fluent workspace (i.e Geometry and Mesh) , it does not have a problem running and the variable value is changed seamlessly.

       

    • Rob
      Forum Moderator

      Then you'll need to set the cell sizing based on the geometry. It can be done, but generally isn't because it's not usually necessary. 

      Everything can be done, and can be automated. It's just that in many cases it's excessively complicated and may take longer than doing it manually. I could journal all of my Fluent model set up, but I don't because the GUI makes it easy. I do journal things that might take me a long time or are very repetitive. 

    • Anagh Dave
      Subscriber

      I was indeed thinking about using a journal file too for this . However , I don't have any experience in it's implementation.I will explore and try to understand it if there is no other alternative.

Viewing 58 reply threads
  • The topic ‘Specific heat UDF energy imbalance’ is closed to new replies.