-
-
April 12, 2024 at 10:32 amSUMEET ANANDSubscriber
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?
-
April 12, 2024 at 10:53 amRobForum Moderator
Are the charging and discharging cycle times known, or do you need to trigger the change based on a solved value?
-
April 12, 2024 at 1:28 pmSUMEET ANANDSubscriber
No, the charging and discharging time cycle is not known. The cycle time would be calculated based on PCM's complete melting and solidification.Â
-
April 12, 2024 at 1:40 pmRobForum 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.Â
-
April 26, 2024 at 4:59 amSUMEET ANANDSubscriber
Ok sir
Thankyou @Rob
-
April 26, 2024 at 8:48 amRobForum Moderator
You're welcome. As pyFluent expands that may give you more options too. Check the Ansys GitHub for more details on that.
-
April 26, 2024 at 9:17 amsumeet94Subscriber
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?Â
-
April 26, 2024 at 9:34 amsumeet94Subscriber
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.   Â
-
April 26, 2024 at 10:30 amRobForum 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.Â
-
April 26, 2024 at 11:37 amsumeet94Subscriber
Thank you for your response.Â
-
April 30, 2024 at 1:59 pmsumeet94Subscriber
 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 commandCan you please suggest how to resolve this error.
-
April 30, 2024 at 2:17 pmRobForum 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.Â
-
April 30, 2024 at 3:00 pmsumeet94Subscriber
I started the command with define/..... (or) /define/....., but it had the same error.
-
April 30, 2024 at 3:24 pmRobForum 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?Â
-
April 30, 2024 at 4:46 pmsumeet94Subscriber
Yes, it works.
-
May 1, 2024 at 4:49 amsumeet94Subscriber
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?
-
May 1, 2024 at 9:23 amRobForum Moderator
Does the IF statement declare greater, equal or less than the value?Â
-
May 1, 2024 at 10:02 am
-
May 1, 2024 at 10:14 amRobForum 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.Â
-
May 2, 2024 at 5:12 amsumeet94Subscriber
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?
-
May 2, 2024 at 11:10 amRobForum Moderator
Again, check your report returns exactly 0, and not 0.0000000000000000000000000000000001 : it's generally a better idea to set bounds using < >Â
-
May 18, 2024 at 11:58 amsumeet94Subscriber
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?
-
May 20, 2024 at 9:28 amRobForum 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?
-
- The topic ‘Melting and solidification process for different boundary condition& time period’ is closed to new replies.
- error udf
- Help: About the expression of turbulent viscosity in Realizable k-e model
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- Fluent fails with Intel MPI protocol on 2 nodes
- Cyclone (Stairmand) simulation using RSM
- Diesel with Ammonia/Hydrogen blend combustion
- Non-Intersected faces found for matching interface periodic-walls
- Mass Conservation Issue in Methane Pyrolysis Shock Tube Simulation
- Encountering Error in Heterogeneous Surface Reaction
- Fan rotation using Fluent Meshing , Error : “Activate Global Domain”
-
1156
-
488
-
481
-
225
-
201
© 2024 Copyright ANSYS, Inc. All rights reserved.