We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Problem with C_YI(c,t,i)

    • isaps1860
      Subscriber

      I have an UDF Code in which the the velocity and the mass fraction should be read in and give out a value of a table which is coded in. Example of the code for the velocity and mass frac:

      real xinput = C_U(c,t);

      real yinput =C_YI(c,t,i);


      For the velocity the code works and the code works fine if I put a value for C_YI(c,t,i) --> real yinput=0,19.

      But if I let C_YI(c,t.i) in the code, I get an error code 999999 and fluent crashes...

      Is there an additionally thing for the C_YI(c,t,i) macro I have to pay attention or what can be the problem?

    • aitor.amatriain
      Subscriber
      Have you defined the value of the species index (i)?
    • isaps1860
      Subscriber
      No I didn┬┤t define the value of the species index (i). Is this necessary? In the examples I have read there were no closer executions about i except the int i; -line
    • aitor.amatriain
      Subscriber
      Yes, you need to specify the species index
    • isaps1860
      Subscriber
      Thank you very much, is there an example for the specifying of the species index?
    • aitor.amatriain
      Subscriber
      As far as I am concerned, starting from 0, the order is the same as the list appearing in the "Mixture" section in the "Materials" panel.
    • isaps1860
      Subscriber
      Thanks for the answer but the problem still exists...Fluent also crashes with C_YI(c,t,0), C_YI(c,t,1) or other number values
      Cannot understand why with C_U(c,t) everything is fine and with C_YI(c,t,i) theres a problem. Scheme is the same (except the i factor)
    • aitor.amatriain
      Subscriber
      Try to use C_YI in a simpler UDF (for example, you could define it as a post-processing variable by means of DEFINE_ADJUST macro).
    • Rob
      Forum Moderator
      As says C_YI(c,t,0) ought to pick up the first species in the mixture list. Please can you post the exact error message in it's entirety?
    • isaps1860
      Subscriber
      The exact error message in the console window is:
      "999999: mpt_accept: error: accept failed: No error"
      and this message several times before Fluent crashes and closes
    • Rob
      Forum Moderator
      That's a parallel code warning. Is there anything just above that?
    • isaps1860
      Subscriber
      Yes there┬┤s another error message above but because Fluent closes automatically after initializing or running the code, I couldn┬┤t get it. I will try to screenshot it on console if I will be fast enough :D

    • isaps1860
      Subscriber
      Node 0: Process 19356: Received signal. SIGSEV.
      Is the first output in console after initializing or running
    • aitor.amatriain
      Subscriber
      Could you please shows us the UDF (code)?
    • Rob
      Forum Moderator
      So the value doesn't exist and is then called. Can you initialise and then hook up the code? You're defining real yinput =C_YI(c,t,i); but depending on the order things are called C_YI(c,t,i) has no value until it's initialised.
    • isaps1860
      Subscriber
      #include "udf.h"
      #include
      #include
      DEFINE_SOURCE(source, c, t, dS, eqn)
      {
      Thread *tm=THREAD_SUPER_THREAD(t);
      Thread **pt = THREAD_SUB_THREADS(tm);
      Thread *tp = pt[0];
      Thread *ts = pt[1];
      Thread *sec;

      real source;
      int i;

      typedef struct
      {
      double xCoordinate;
      double yCoordinate;
      double zCoordinate;
      } Point;

      int data[100];
      int number_of_points = 25;
      Point points[25];
      int main();
      {

      Point test;
      Point test2 ={1, 2, 3};
      test.xCoordinate = 1;
      points[0].xCoordinate = 0; points[0].yCoordinate = 0; points[0].zCoordinate = 0.0978;
      points[1].xCoordinate = 0; points[1].yCoordinate = 0.10; points[1].zCoordinate = 0.068;
      points[2].xCoordinate = 0; points[2].yCoordinate = 0.20; points[2].zCoordinate = 0.0532;
      points[3].xCoordinate = 0; points[3].yCoordinate = 0.30; points[3].zCoordinate = 0.0132;
      points[4].xCoordinate = 0; points[4].yCoordinate = 0.40; points[4].zCoordinate = 0.0324;

      points[5].xCoordinate = 0.5; points[5].yCoordinate = 0; points[5].zCoordinate = 0.0244;
      points[6].xCoordinate = 0.5; points[6].yCoordinate = 0.10; points[6].zCoordinate = 0.0166;
      points[7].xCoordinate = 0.5; points[7].yCoordinate = 0.20; points[7].zCoordinate = 0.011;
      points[8].xCoordinate = 0.5; points[8].yCoordinate = 0.30; points[8].zCoordinate = 0.05;
      points[9].xCoordinate = 0.5; points[9].yCoordinate = 0.40; points[9].zCoordinate = 0.0092;

      points[10].xCoordinate = 1; points[10].yCoordinate = 0; points[10].zCoordinate = 0.0264;
      points[11].xCoordinate = 1; points[11].yCoordinate = 0.10; points[11].zCoordinate = 0.0148;
      points[12].xCoordinate = 1; points[12].yCoordinate = 0.20; points[12].zCoordinate = 0.011;
      points[13].xCoordinate = 1; points[13].yCoordinate = 0.30; points[13].zCoordinate = 0.0116;
      points[14].xCoordinate = 1; points[14].yCoordinate = 0.40; points[14].zCoordinate = 0.0444;

      points[15].xCoordinate = 1.5; points[15].yCoordinate = 0; points[15].zCoordinate = 0.0256;
      points[16].xCoordinate = 1.5; points[16].yCoordinate = 0.10; points[16].zCoordinate = 0.0132;
      points[17].xCoordinate = 1.5; points[17].yCoordinate = 0.20; points[17].zCoordinate = 0.0094;
      points[18].xCoordinate = 1.5; points[18].yCoordinate = 0.30; points[18].zCoordinate = 0.0092;
      points[19].xCoordinate = 1.5; points[19].yCoordinate = 0.40; points[19].zCoordinate = 0.258;

      points[20].xCoordinate = 2; points[20].yCoordinate = 0; points[20].zCoordinate = 0.027;
      points[21].xCoordinate = 2; points[21].yCoordinate = 0.10; points[21].zCoordinate = 0.014;
      points[22].xCoordinate = 2; points[22].yCoordinate = 0.20; points[22].zCoordinate = 0.0106;
      points[23].xCoordinate = 2; points[23].yCoordinate = 0.30; points[23].zCoordinate = 0.0122;
      points[24].xCoordinate = 2; points[24].yCoordinate = 0.40; points[24].zCoordinate = 0.5102;

      real xInput = C_U(c,tp);
      real yInput = C_YI(c,ts,i);

      printf("x = %.3f, y = %.3f", xInput, yInput);

      Point neighbors[4];
      neighbors[0] = points[0];
      neighbors[1] = points[0];
      neighbors[2] = points[0];
      neighbors[3] = points[0];

      for (int g = 0; g < number_of_points; g++)
      {
      Point currentPoint = points[g];

      if (currentPoint.xCoordinate == floor(xInput))
      {
      if (currentPoint.yCoordinate == floor(yInput))
      {
      neighbors[0] = currentPoint;

      }
      if (currentPoint.yCoordinate == ceil(yInput))
      {
      neighbors[1] = currentPoint;

      }
      }

      if (currentPoint.xCoordinate == ceil(xInput))
      {
      if (currentPoint.yCoordinate == floor(yInput))
      {
      neighbors[2] = currentPoint;

      }
      if (currentPoint.yCoordinate == ceil(yInput))
      {
      neighbors[3] = currentPoint;

      }
      }

      if (currentPoint.xCoordinate <= xInput)
      {
      if (currentPoint.yCoordinate <= yInput)
      {
      if (xInput - currentPoint.xCoordinate <= xInput - neighbors[0].xCoordinate)
      {
      if (yInput - currentPoint.yCoordinate <= yInput - neighbors[0].yCoordinate)
      {
      neighbors[0] = currentPoint;
      }
      }
      }
      }

      if (currentPoint.xCoordinate >= xInput)
      {
      if (currentPoint.yCoordinate <= yInput)
      {
      if (neighbors[2].xCoordinate < xInput)
      {
      neighbors[2] = currentPoint;
      }

      if ((currentPoint.xCoordinate - xInput <= neighbors[2].xCoordinate - xInput))
      {
      if (yInput - currentPoint.yCoordinate <= yInput - neighbors[2].yCoordinate)
      {
      neighbors[2] = currentPoint;
      }
      }
      }
      }

      if (currentPoint.xCoordinate <= xInput)
      {

      if (currentPoint.yCoordinate >= yInput)
      {

      if ((xInput - currentPoint.xCoordinate <= xInput - neighbors[1].xCoordinate))
      {

      if (neighbors[1].yCoordinate < yInput)
      {
      neighbors[1] = currentPoint;
      }

      if (currentPoint.yCoordinate - yInput <= neighbors[1].yCoordinate - yInput )
      {

      neighbors[1] = currentPoint;

      }
      }
      }
      }

      if (currentPoint.xCoordinate >= xInput)
      {
      if (currentPoint.yCoordinate >= yInput)
      {
      if (neighbors[3].xCoordinate < xInput)
      {
      neighbors[3] = currentPoint;
      }

      if ((currentPoint.xCoordinate - xInput <= neighbors[3].xCoordinate - xInput))
      {
      if (neighbors[3].yCoordinate < yInput)
      {
      neighbors[3] = currentPoint;
      }
      if ( currentPoint.yCoordinate - yInput <= neighbors[3].yCoordinate - yInput)
      {
      neighbors[3] = currentPoint;
      }
      }
      }
      }
      }


      double leftVertex = neighbors[0].zCoordinate + (neighbors[1].zCoordinate - neighbors[0].zCoordinate) / (neighbors[1].yCoordinate - neighbors[0].yCoordinate) * (yInput - neighbors[0].yCoordinate);
      double rightVertex = neighbors[2].zCoordinate + (neighbors[3].zCoordinate - neighbors[2].zCoordinate) / (neighbors[3].yCoordinate - neighbors[2].yCoordinate) * (yInput - neighbors[2].yCoordinate);
      double result = leftVertex + (rightVertex - leftVertex) / (neighbors[2].xCoordinate - neighbors[0].xCoordinate) * (xInput - neighbors[0].xCoordinate);
      printf("result : %f\n", result);

      source = result;

      dS[eqn] = 0;
      return source;
      }
      }
    • isaps1860
      Subscriber
      Thank you for the note, that this error means a value is missing. But the result by starting it after the initialisation is the same
    • aitor.amatriain
      Subscriber
      It seems that the value of the integer "i" is undefined
    • isaps1860
      Subscriber
      Yes, in the sended code there is no definition of "i". But I┬┤ve also tried with the definition of 0 and 1 and the code crashes
      --> int i = 0; or also
      --> C_YI(c,ts,0)
    • aitor.amatriain
      Subscriber
      Both species are present in both phase, right? If yes, either the second argument is wrong, or the macroC_YI is not valid for multiphase flows. I am not an expert in advanced multiphase macros, so I cannot help you.
Viewing 19 reply threads
  • The topic ‘Problem with C_YI(c,t,i)’ is closed to new replies.