Ansys Learning Forum Maintenance

NOTICE: We will be performing backend maintenance of our Learning Forum from April 5 to April 12, 2021. The result will be a new infrastructure but with little impact to user experience and design. Currently the forum is accessible in read-only mode as we complete our final migration. Thank you for your patience. For urgent issues please visit HERE.


assigning specific value for mass in domain — Ansys Learning Forum

assigning specific value for mass in domain

mkalelmkalel Member Posts: 23

Is there an option in Fluent where I can assign a Specific value for the mass in the domain? To be more specific, I am trying to supply mass in the domain (exactly 0.04 KG) of the particle into the system and trying to stop the simulation to see the exact time step needed for that time.


How can I do that so that I don't supply more mass to the system than I wanted.?

Thanks

Answers

  • YasserSelimaYasserSelima Member Posts: 929

    Through a UDF

    Make a global variable to save the amount of mass injected ... and pass a variable to the solver, and set a convergence criteria based on this variable.

    there was a post here before where someone wanted to stop the simulation from the UDF .. search for it

  • mkalelmkalel Member Posts: 23

    I never did the UDF before. I want to stop it when the mass in the domain reaches 0.04 kg.

    I tried this UDF . Does this look even right???


    #include "udf.h"

    #include "var.h"


    DEFINE_MASS_IN_DOMAIN(interrupt_sim,d)

    {


    Thread*t= Lookup_Thread(domain.ID);

    cell_t c;

    int x = 0;


    thread_loop_c(t,d)

    {

    begin_c_loop(c,t)

    {

    if (c_t(c,t)=0.04)

    {

    x=1;

    break;

    }

    }

    end_f_loop(f,t)

    break;

    }

    x=PRF_GIHIGH1(X);

    if(X==1)

    RP_set_integer(interrupt/flag",1);

    }

  • YasserSelimaYasserSelima Member Posts: 929
    edited April 4

    First, is there a macro called DEFINE_MASS_IN_DOMAIN ?? there are tons of macros that loops over the DPM ... go to the manual and select the one that fits your function. I am not sure which one, but if you did not find one, define adjust would be your last choice

    Second, and I will try to explain this clearly because of the forum closure, I will not be able to reply in the coming day ... in the scheme, create a real variable let's say you call it "stop_order" ... and in your UDF you create a global variable .. let's say "order_to_stop" ... and in your function you put IF statement to change this variable every timestep ... and when the condition is met, you keep this variable without change. And pass this variable to the solver every time step using RP_Set_Real ... Now in the monitors, residuals, add convergence criteria for this variable to stop iterations when this variable converge

    Third PRF_GRSUM1(x) is the macro you need to parallelize global sum, not PRF_GIHIGH1(X) .


    #include "udf.h"
    static real order_to_stop=0;
    static int flag = 1; 
    DEFINE_ ... ()
    {
       real MASS = 0.0;
       /* SUM THE MASS HERE */
       {
         ...
       }
       MASS = PRF_GRSUM1(MASS);
       if (MASS > 0.04 && int_flag == 1) 
       {
           flag = 0;
       } else {
           order_to_stop += 0.001 ;
       }
       RP_Set_Real("stop_order",  order_to_stop);
    }
    
  • mkalelmkalel Member Posts: 23

    Hello @YasserSelima ,

    Thank you very much for your support and help. I appreciate your help.

    I totally understand about the forum disclosure thing. we all have to maintain that forum policy as well.

Sign In or Register to comment.