Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Write UDF code of Heat Generation rate q for 18650 Li-ion battery cell.

    • tandinhtamky
      Subscriber

      Hi there,

      I have a problem when i try to create a udf code. The temperature is too high (about 5000 K compare to ~320 K of reference paper)

      I want to simulate the thermal of 1 battery cell: 18650 3400 mah panasonic.

      About a condition, a cell is convection only, and no inlet/outlet in my fluent.

      Here is a equation i followed and udf code upon it.

    • tandinhtamky
      Subscriber
      ah i forgot,
      in
      real soc = 1-(real_time*3.20513e-4);
      in reference paper, i get the total time of 1C discharge is 3120 second. And i calculate SOC linear with time.
    • Rob
      Forum Moderator
      I'll not try and untangle the matrix maths. In the CFD model you're adding W/m3 into a cell zone. If you check the maths have you accounted for that? What are the external boundary conditions of the cell? Default is adiabatic, so the heat has nowhere to go. Are you using any of the battery models?
    • tandinhtamky
      Subscriber
      Thanks for replying me.
      Actually, i dont use any battery models, just a normal model.
      Boundary condition, wall condition, ... i had. I only nervous in UDF heat source, about syntax, how code work.
      On the other hand, i so nervous about thermal conductivity. Because it's orthotropic, i use cyl-orthotropic. It have 3 direction of thermal cond: radial, axial, tangential. The value of thermal conductivity in radial direction is 0.05.
      I tried this case: (to know do my simulation work fine without udf.
      Set heat generation rate to constant value. Every other condition is not change. Result show that it's divergence !
      If i still set heat generation rate to constant value, but value of thermal conductivity in radial direction is 5 (100 times compare to true value), result show that it's convergence completely !
      I think if value of thermal conductivity is too small, it will be affect on result. Please tell me why ?

    • Rob
      Forum Moderator
      What's the external wall bc set as? By default it's adiabatic so adding heat will just mean you have an infinite temperature, well 5000K as that's the default limiter.
      The divergence could just be down to the solver trying to create the temperature gradients, hard to judge without seeing some images and knowing what you've set up.
    • tandinhtamky
      Subscriber
      Hi sir, here is my setup.

      Method and controls i leave it default.

    • DrAmine
      Ansys Employee
      So you have only one cell zone which is solid and using constant source term and it is diverging? Is it a summary of your problem? If you set the heat conductivity to planar / constant in all direction: will it work? Does the axial direction corresponds to (0,0,1) in your cell zone: is it a correct axis of rotation?
    • Rob
      Forum Moderator
      OK, so that should stabilise at a set temperature based on the heat input and external heat transfer. How big is the domain?
    • tandinhtamky
      Subscriber
      Domain is just a battery cell: 18mm diameter and 65 height. That's all.
    • tandinhtamky
      Subscriber
      Thanks for reply me !
      i have some confused about it. i dont understand what axis origin/direction is? But, the axial direction in my model is z direction.

      So you have only one cell zone which is solid and using constant source term and it is diverging? Is it a summary of your problem?
      yes.
      If you set the heat conductivity to planar / constant in all direction: will it work
      yes it work !!

    • Rob
      Forum Moderator
      If you go to the Scale option can you check the dimensions? I want to eliminate you having an 18m diameter battery that's 65m long. Please post an image of the mesh, and temperature contour for one of the working models.
    • tandinhtamky
      Subscriber
      Scale here:
      Mesh here:
      Contour temperature of case: cyl-orthotropic (thermal conductivity), heat source is constant = 80000. After 60 second.


    • Rob
      Forum Moderator
      Remesh with a pave mesh rather than trying to force a map mesh on the face. The problem is likely caused by the squashed cells at the "corners". If you REALLY want a block mesh use an O-grid.
    • tandinhtamky
      Subscriber
      Thanks for your instruction. I will try tomorrow, because now is 1:00 AM in my country. Next morning i will reply. Sorry about that sir :(
    • tandinhtamky
      Subscriber
      Everything not change, sir.
      Here is re-mesh.
      transient or steady, if i use cyl-orthotroic thermal conductivity, both will divergence, temperature blow up to 5000K.
      If i use same thermal conductivity in all direction, it convergence quite fast.
      Please help mel, Sir !

    • Rob
      Forum Moderator
      OK, so mesh has been eliminated. If you do a hand calc using the external wall boundary, you know Q, A and free stream T, what temperature will the cell reach?
    • tandinhtamky
      Subscriber
      Temperature about 320K ~ 330K. But, can very low value of thermal conductivity induce bad-effect to result, sir?
      Actually now i dont care what is exact value, just have a reasonable temperature is enough.
    • Rob
      Forum Moderator
      It's more whether you're getting silly gradients. Looking at the conductivity values, a conductivity of 0.05 shouldn't cause a problem in itself, but combine that with the conductivity of 850 in the other directions and heat load you may need more mesh to pick up the temperature gradients.
    • DrAmine
      Ansys Employee
      The combination is doing this odd job. I also can obtain similar odd results but a finer grid resolution will correct the behavior and counter work the biasing of heat conductivity.
      Better to allocate the cells in the regions where a change is there. Cylinder is bit difficult to have a better grid distribution but I recommend to rely on O-Grid and hex map mesh.
      There is another method dealing with noise in the energy equation but it might be insufficient here.
    • tandinhtamky
      Subscriber
      Hi sir DrAmine and sir Rob Yeahhhh, looks like it worked, with above 300 000 cell !! Thank you so much.
      Now, the problem is udf code for heat generation rate only :)))
      Here is result with udf code


    • tandinhtamky
      Subscriber
      Here is my udf code
      include "udf.h"
      #include "math.h"
      #define I 3.4
      DEFINE_SOURCE(heat_gen_rate, cell, thread, dS, eqn)
      {
      real temp = C_T(cell, thread);
      real real_time = CURRENT_TIME;
      real soc = 1-(real_time*3.20513e-4);
      real q=0;
      real u=0;
      real a[5][5] = {{174.87,-4.2857,0.063921,0.00056216,2.2924e-6} {-421.73,-11.846,0.65394,0.0074809,0.00002289} {710.11,58.26,-1.8389,-0.007132,0.00007878} {-483.23,-84.388,2.0758,-0.0029176,-0.0002021} {130.58,37.67,-0.83495,0.003493,0.00010523}};

      real b[6][6] = {{218.49,-6.7907,-0.026023,0.0042377,-0.0000666,3.2778e-7} {-2064.3,53.454,0.53007,-0.029377,0.0002498,-1.9726e-7} {7960.5,-181.44,-2.1533,0.064345,0.0003483,-8.6883e-6} {-14556.0,306.86,3.5406,-0.036523,-0.0026742,0.00003051} {12619.0,-251.06,-2.6282,-0.028271,0.0038013,-0.0000372} {-4166.1,78.657,0.75196,0.025085,0.0016507,0.0000152}};

      real c[6] = {4.8,-13.93,2.042,32.81,-38.54,13.02};

      int i;
      int j;
      for (j=0;j<5;j++)
      {
      for (i=0;i<5;i++)
      {
      q=q+(a[i][j]*pow(soc,i)*pow(temp,j));
      }
      }


      for (j=0;j<6;j++)
      {
      for (i=0;i<6;i++)
      {
      q=q+(b[i][j]*pow(soc,i)*pow(temp,j));
      }
      }
      q=pow(I,2)*q;


      for (i=0;i<6;i++)
      {
      u=u+(c[i]*pow(soc,i));
      }
      u=u*I*temp;

      q=q+u;
      dS[eqn]=0;
      return q;
      }
    • tandinhtamky
      Subscriber
      I want to update somthing.
      I tried to ensure the function & working of define-funcion, CURRENT TIME or C_T(thread, cell), everything is ok.
      i also tried to ensure double summation is working through this code.
      Now i dont know where i were wrong ­ƒÑ▓

Viewing 21 reply threads
  • The topic ‘Write UDF code of Heat Generation rate q for 18650 Li-ion battery cell.’ is closed to new replies.
[bingo_chatbox]