Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Melting and solidification process for different boundary condition& time period

    • SUMEET ANAND
      Subscriber

      Hello, everyone. I am simulating the melting and solidification behavior of phase change material (PCM) in the heat pipe for subsequent time cycles. Cold fluid flows in the inner pipe while the PCM is stored in the annulus region of the heat pipe. During the charging process, the flux boundary condition at the outer surface of the heat pipe is applied, while during the discharging process, the convection boundary condition is given at the outer surface of the heat pipe. For this, I have to write the UDF in such a way that when the PCM completely melts during the charging process, the convection boundary condition automatically applies. Once it completely solidifies during the discharging process, the heat flux boundary condition activates again, and similarly, the convection boundary condition activates when PCM completely melts. So, this melting and solidification process continues for different time periods. Can anyone please help?

    • Rob
      Forum Moderator

      Are the charging and discharging cycle times known, or do you need to trigger the change based on a solved value?

    • SUMEET ANAND
      Subscriber

      No, the charging and discharging time cycle is not known. The cycle time would be calculated based on PCM's complete melting and solidification. 

    • Rob
      Forum Moderator

      Not easy then as changing boundary settings is non-trivial from UDFs and may require Scheme commands. It's also beyond what I can assist with on the Forum as it's not in the public domain documentation. 

    • SUMEET ANAND
      Subscriber

      Ok sir

      Thankyou @Rob

    • Rob
      Forum Moderator

      You're welcome. As pyFluent expands that may give you more options too. Check the Ansys GitHub for more details on that.

    • sumeet94
      Subscriber

      I am trying to write the conditional statement in the named expression tab using the IF statement based on the PCM solidus and liquids temperature, as IF(T_avg(PCM)<=514 K, heat flux boundary condition, convection boundary condition). The IF condition statement provided in the Ansys named expression is given below, 

      IF(Average(T,['pcm_domain'],Weight='Volume')<=514 [K],20000 [W m^-2],10[W m^-2 K^-1]*((Average(T,['tube_outer_surface'],Weight='Area'))-300[K]))

      where 514 K denotes the PCM liquidus temperature, 20000 [W m^-2] denotes the heat flux, 10[W m^-2 K^-1]*((Average(T,['tube_outer_surface'],Weight='Area'))-300[K]) denotes the convection boundary, 300 K is the ambient temperature, respectively.

      The convection boundary condition applies as the average PCM temperature exceeds 514 K. However, the problem occurred when the PCM average temperature started to decrease. As the PCM temperature slightly decreases from 514 K, the flux boundary condition is applied again. So, can you please give some idea on how to resolve this issue so that the PCM melts and solidifies based on the PCM temperature for different consecutive time cycles? 

    • sumeet94
      Subscriber

      I am trying to write the conditional statement in the named expression tab using the IF statement based on the PCM liquidus temperature as IF(T_avg(PCM)<=514 K, heat flux boundary condition, convection boundary condition). The IF condition statement provided in the Ansys named expression is given below, 

      IF(Average(T,['pcm_domain'],Weight='Volume')<=514 [K],20000 [W m^-2],10[W m^-2 K^-1]*((Average(T,['tube_outer_surface'],Weight='Area'))-300[K]))

      where, 514 K denotes the PCM liquidus temperature, 20000 [W m^-2] denotes the heat flux, 10[W m^-2 K^-1]*((Average(T,['tube_outer_surface'],Weight='Area'))-300[K]) denotes the convection boundary, 300 K is the ambient temperature, respectively.

      The convection boundary condition applies when the PCM domain temperature exceeds 514 K. However, the problem occurred when the PCM domain temperature slightly decreased from 514 K (due to the convection boundary condition), and the heat flux boundary condition was applied again. So, can you please suggest how to resolve this issue so that the PCM domain temperature decreases to its solidus temperature (494 K) without using the flux boundary condition? Also, the PCM melts and solidifies in a similar fashion for another time cycle.      

    • Rob
      Forum Moderator

      It will; the IF statement means that as soon as the PCM < 514K 20,000 W/m2 is applies, as soon as it is over 514K the other flux applies. It's not a IF then stay effect. You may be able to use the equivalent of the Expression in a UDF with nested IFs? You'll need another condition to retain one or other of the wall states until something else happens. 

      Nice idea, I'd not thought of that, and wouldn't have been able to suggest it either. 

    • sumeet94
      Subscriber

      Thank you for your response. 

    • sumeet94
      Subscriber

       I have written the scheme command based on the PCM solidus and liquidus temperature,

      (if(ti-menu-load-string (format #f "report/volume-integrals/volume-avg pcm_domain () temperature no"))=494)
      (
      (ti-menu-load-string "define/boundary-conditions/wall tube_outer_surface 0 no 0 no yes heat-flux no 20000 no no 0 no 1)
      )
      (if(ti-menu-load-string (format #f "report/volume-integrals/volume-avg pcm_domain () temperature no"))=514)
      (
      (ti-menu-load-string "define/boundary-conditions/wall tube_outer_surface 0 no 0 no yes convection no 10 no 300 no no 0 no 1)
      )

      However, an error is showing while executing the scheme command

      Can you please suggest how to resolve this error.

    • Rob
      Forum Moderator

      You may want to be more careful with TUI syntax, if you start a command with define (for example) it'll trigger that command from whatever TUI menu level you're in. However /define will trigger from the root level menu. That may fix your issue. Otherwise you need to check all of the commands, both TUI and the Scheme wrapper. 

    • sumeet94
      Subscriber

      I started the command with define/..... (or) /define/....., but it had the same error.

    • Rob
      Forum Moderator

      And if you try the /define/boundary-conditions/wall command manually does the rest of that line work through as in the Scheme command? 

    • sumeet94
      Subscriber

      Yes, it works.

    • sumeet94
      Subscriber

      I have modified the scheme command as shown below, 

      And while executing the scheme command, it does not show any error, as shown below,

      However, the problem is that when the pcm_domain temperature reaches the PCM liquidus temperature, the boundary condition doesn't change from heat flux to convection. Can you please suggest why this is happening so?

    • Rob
      Forum Moderator

      Does the IF statement declare greater, equal or less than the value? 

    • sumeet94
      Subscriber

      Equal to condition has been given with the IF statement, as shown below

       

    • Rob
      Forum Moderator

      That's unlikely to trigger. The chances of a report returning precisely 494K (from your command) are pretty much zero, even 493.999999999999999999K won't trigger it. Remember, the report is a real number to solver accuracy and you're trying to equate that to an integer. 

    • sumeet94
      Subscriber

      Ok, I understood from your comment that a precise value has a very low probability of returning the same value. In that case, as we know, the liquid fraction varies from 0 to 1, so I replaced the conditional statement with the liquid fraction variable in place of the pcm_domain temperature. However, the problem remains the same, i.e., the boundary condition doesn't change. Initially, I started the simulation by applying the convection boundary condition so that while executing the scheme command, it would satisfy my first condition (i.e., IF(liquid fraction = 0)) as the liquid fraction is zero initially. However, the boundary condition doesn't change to heat flux in this case. Any comment?

    • Rob
      Forum Moderator

      Again, check your report returns exactly 0, and not 0.0000000000000000000000000000000001 : it's generally a better idea to set bounds using < > 

    • sumeet94
      Subscriber

      Sir, I wrote a UDF regarding the above-stated problem, which is given below,

      #include "udf.h"
      real pcm_tavg;
      real gc_tavg;

      #define T_S 494  /*pcm solidus temperature*/
      #define T_L 514  /*pcm liquidus temperature*/
      #define h 10 /*heat transfer coefficient*/
      #define T_amb 300 /*ambient temperature*/

      /* CALCULATING THE PCM DOMAIN VOLUME WEIGHTED AVERAGE TEMPERATURE*/

      DEFINE_EXECUTE_AT_END(pcm_domain_average_temperature)
      {
      statement
      ----------
      pcm_tavg = -----;
      }

      /* CALCULATING THE GLASS COVER AREA WEIGHTED AVERAGE TEMPERATURE*/

      DEFINE_EXECUTE_AT_END(glass_cover_average_temperature)
      {
      statement
      ----------
      gc_tavg = -----;
      }

      /* APPLYING CHARGING AND DIS-CHARGING BOUNDARY CONDITION */
       
      DEFINE_PROFILE(bound_condition,thread,position)
      {
          real x[ND_ND];
          real current_time = CURRENT_TIME;
          int current_time_step = N_TIME;
          real current_time_step_size = CURRENT_TIMESTEP;
          real total_time = current_time_step*current_time_step_size;
          current_time=0;
       #if !RP_HOST
              face_t face;
              while(current_time<=total_time)
              {
                  begin_f_loop(face,thread)
                  {
                      if(pcm_tavg>=T_L)
                      {
                          Message("pcm completely melts, pcm_Tavg = %g\n",v_w_tavg);
                          while(current_time<=total_time)
                          {
                              begin_f_loop(face,thread)
                                  {
                                     if(pcm_tavg<=T_S)
                                      {
                                          Message("pcm completely solidifies, pcm_Tavg = %g\n",v_w_tavg);
                                          break;
                                      }                                    
                                      else
                                      { 
                                          F_CENTROID(x,face,thread);
                                          F_PROFILE(face,thread,position) = h*(T_amb-gc_tavg);
                                      }
                                  }
                              end_f_loop(face,thread)
                             current_time = current_time + current_time_step_size; 
                          }                    
                      }
                      else
                      {
                      F_CENTROID(x,face,thread);
                      F_PROFILE(face,thread,position) = 20000;
                      }
                  }
                  end_f_loop(face,thread)
                  current_time = current_time + current_time_step_size;
              }
          #endif    
      }

      First, I calculated the PCM domain volume-weighted average temperature and area-weighted average temperature for the glass cover outer surface, respectively, using the UDF - DEFINE_EXECUTE_AT_END macros, as shown in the UDF above. These two UDFs work fine.  

      The change of boundary condition is done by using the DEFINE_PROFILE macro. Initially, the flux value applies as per the condition. But, the problem arises when the PCM average temperature exceeds the T_L; it doesn't enter the if condition statement of the 1st while statement; rather, it continues with the else statement. Can you please suggest why the if statement doesn't work?

    • Rob
      Forum Moderator

      What stops the UDF returning a solid/frozen result which triggers the change in boundary condition, but in the following step the zone is nolonger frozen which then triggers the fluid setting? Have a very careful look at how your IF statements link - would IF AND type logic make more sense? 

      What is  while(current_time<=total_time) for?

Viewing 22 reply threads
  • The topic ‘Melting and solidification process for different boundary condition& time period’ is closed to new replies.