Fluids

Fluids

UDF NEW SOURCE

    • Jancos
      Subscriber

      Hi all,


      Can anyone help me with this UDF. After I interpreted my UDF , set UDMs on 4 and put new momentum source I initializate my calculation but when I am checking counturs the values of my UDMs are 0. And when I start calculation my Fluent crashed. 


      THIS MY UDF:


       

    • DrAmine
      Ansys Employee
      We will provide guidance only. Paste the lines here.
    • Jancos
      Subscriber

      #include "udf.h"


       


      #define N 94208


      #define xm -8.86E-9


      #define ro 997.96


      #define beta 21.37E-5


      #define To 298.5


      #define mi 12.566E-7


      #define vf 3.28E-5


       


       


      float GradB[N] =


      {...};// my values number of elements 94208


       


      DEFINE_SOURCE(xmagnetic_source,c,t,dS,eqn)


      {


      real xm_source;


      real Temp;


      Domain *d;


      int i;


      i = 0;


       


      thread_loop_c(t,d)// loop over all cells in model


      {


      begin_c_loop(c,t)


      {


      Temp = C_T(c,t);


      xm_source=(-((xm*ro*beta*(Temp-To)*GradB*vf)/(2*mi)));


      C_UDMI(c,t,0) = GradB;


      C_UDMI(c,t,1) = xm_source;


      i++;


      }


      end_c_loop(c,t)


      }


      return xm_source;


      }


      DEFINE_SOURCE(ymagnetic_source,c,t,dS,eqn)


      {


      real ym_source;


      real Temp;


      Domain *d;


      int i;


      i = 0;


       


      thread_loop_c(t,d)// loop over all cells in model


      {


      begin_c_loop(c,t)


      {


      Temp = C_T(c,t);


      ym_source=(-((xm*ro*beta*(Temp-To)*GradB*vf)/(2*mi)));


      C_UDMI(c,t,2) = ym_source;


      i++;


      }


      end_c_loop(c,t)


      }


      return ym_source;


      }


      DEFINE_SOURCE(zmagnetic_source,c,t,dS,eqn)


      {


      real zm_source;


      real Temp;


      Domain *d;


      int i;


      i = 0;


       


      thread_loop_c(t,d)// loop over all cells in model


      {


      begin_c_loop(c,t)


      {


      Temp = C_T(c,t);


      zm_source=(-((xm*ro*beta*(Temp-To)*GradB*vf)/(2*mi)));


      C_UDMI(c,t,3) = zm_source;


      i++;


      }


      end_c_loop(c,t)


      }


      return zm_source;


      }

    • DrAmine
      Ansys Employee
      Actually there is no need to do a loop inside of a define source udf. Check the manual for more details and attend a training if possible. Gradb is declares but not defined. You require a loop if the counter i if you need to use values from the array.
    • Jancos
      Subscriber

      In my array i have values which represent gradient of magnetic field in every cell center, so I need to have it . And my loop in define source calculate in every cell value of magnetic buoyacy force. Do you have any idea how write this UDF?


       

    • DrAmine
      Ansys Employee
      Check the manual and standard C manuals.
Viewing 5 reply threads
  • You must be logged in to reply to this topic.