custom phase changing material does not release heat.

17 次查看(过去 30 天)
Problem:
When I adjust the latent heat, there's no change in the temperature curve of the XPS material. I anticipate a stable temperature, ranging between 305K and 320K. So the problem is that the material does not release the absorbed heat.
equations
assert(Cps > 0 && Cpl > 0)
assert(T > 0, 'Temperature must be greater than absolute zero')
T == M.T;
if T >= Tmelt_start && T <= Tmelt_end
phaseChangeRate == {0.001, '1/s'};
else
phaseChangeRate == {0, '1/s'};
end
if phase < 1 && phase > 0
Q == m * Cps * T.der + m * L * phaseChangeRate;
phase.der == phaseChangeRate;
else
Q == m * Cpl * T.der;
phase.der == {0, '1/s'};
end
end
explanation of the full code:
This code describes a thermal component that models internal energy storage in a thermal network. Here's a breakdown of the main parts of this code:
1. **Nodes**: These are points where other components can connect. Two thermal nodes are defined: `M` (top) and `N` (bottom).
2. **Inputs**: These values can be supplied from outside. `Mdot` represents the mass flow rate (in kg/s) and `T_in` is the input temperature (in Kelvin).
3. **Parameters**: These values determine the behavior of the component. They include:
- `mass_type`: Type of mass (constant or variable).
- `mass`: The mass of the thermal component.
- `Cps` and `Cpl`: Specific heat capacity for solid and liquid, respectively.
- `Tmelt_start` and `Tmelt_end`: The temperature range where the material starts melting and stops melting.
- `L`: Specific latent heat.
- `mass_min`: Minimum mass.
- `num_ports`: The number of graphical ports.
4. **Annotations**: These are metadata that provide additional information about the component or dictate how it is displayed in a GUI. Here, it is primarily used to indicate which parameters can be modified externally and to define the component's icon.
5. **Variables**: These represent the internal states of the component. They include:
- `m`: The mass.
- `T`: The temperature.
- `phase`: The phase (0 for solid, 1 for liquid, and values in between for a mixed phase).
- `phaseChangeRate`: The rate of phase change.
- `Q`: Heat flow rate.
6. **Branches**: These are connections between different parts of the network. Here, the heat flow `Q` from node `M` to another part of the network is defined.
7. **Equations**: These describe the mathematical relationships between the different variables and parameters. They include:
- Relationships between `T`, `Q`, `m`, and other variables, especially around phase change.
- Constraints on certain values (like that `Cps`, `Cpl`, and `T` must be positive).
8. **Connections**: These are the actual connections between the different nodes within the component. Here, node `M` is connected to node `N`.
The essence of this component is that it models a thermal mass that can store and release energy. It also accounts for phase changes, meaning it can melt or solidify within a certain temperature range.
component derdecomponent
% Thermal Mass
% This block models internal energy storage in a thermal network.
nodes
M = foundation.thermal.thermal; % :top
end
inputs(ExternalAccess = none)
Mdot = {0, 'kg/s'}; % Mdot:bottom
T_in = {300, 'K'}; % Tin:bottom
end
nodes(ExternalAccess = none)
N = foundation.thermal.thermal; % :bottom
end
parameters
mass_type = foundation.enum.constant_variable.constant; % Mass type
end
parameters (ExternalAccess = none)
mass = {1, 'kg'}; % Mass
end
parameters
Cps = {200, 'J/(kg*K)'}; % Specific heat solid
Cpl = {1000, 'J/(kg*K)'}; % Specific heat liquid
Tmelt_start = {320, 'K'}; % Start Melting Temperature
Tmelt_end = {305, 'K'}; % End Melting Temperature
L = {100, 'J/(kg)'}; % Specific Latent Heat
end
parameters (ExternalAccess = none)
mass_min = {1e-6,'kg'}; % Minimum mass
end
parameters
num_ports = foundation.enum.numPorts2.one; % Number of graphical ports
end
if num_ports == 2
annotations
N : ExternalAccess=modify
end
if mass_type == foundation.enum.constant_variable.constant
annotations
% Icon = 'mass2.svg'
end
else
annotations
% Icon = 'mass4.svg'
end
end
else
if mass_type == foundation.enum.constant_variable.variable
annotations
% Icon = 'mass3.svg'
end
end
end
if mass_type == foundation.enum.constant_variable.constant
annotations
mass : ExternalAccess=modify
end
equations
m == {1,'kg'};
end
else
annotations
[Mdot, T_in, m, mass_min] : ExternalAccess=modify
end
equations
assert(mass_min > 0)
end
end
variables (ExternalAccess=none)
m = {value = {1,'kg'}, priority=priority.high}; % Mass
end
variables
T = {value = {300, 'K'}, priority = priority.high}; % Temperature
phase = {value = {0, '1'}, priority = priority.high}; % Phase
phaseChangeRate = {0, '1/s'}; % Rate of phase change
end
variables (Access=private)
Q = {0, 'W'}; % Heat flow rate
end
branches
Q : M.Q -> *;
end
equations
assert(Cps > 0 && Cpl > 0)
assert(T > 0, 'Temperature must be greater than absolute zero')
T == M.T;
if T >= Tmelt_start && T <= Tmelt_end
phaseChangeRate == {0.001, '1/s'};
else
phaseChangeRate == {0, '1/s'};
end
if phase < 1 && phase > 0
Q == m * Cps * T.der + m * L * phaseChangeRate;
phase.der == phaseChangeRate;
else
Q == m * Cpl * T.der;
phase.der == {0, '1/s'};
end
end
connections
connect(M,N)
end
end

回答(1 个)

Shishir Reddy
Shishir Reddy 2024-8-23,6:46
Hi Berkay
The issue seems to be related to the logic in the phase change model.
‘Tmelt_start’ has been set to 320K and Tmelt_endis set to 305K. This is inverted, typically the melting process starts at a lower temperature and ends at high temperature. So, the values must be swapped.
Tmelt_start = {305, 'K'};
Tmelt_end = {320, 'K'};
In calculating ‘’phaseChangeRate - (T >= Tmelt_start && T <= Tmelt_end)’ – This condition only checks if the temperature T is within the range where phase change can occur. But it should also be ensured that ‘phaseChangeRate’ should be applied only when the material is neither fully solid (phase == 0) nor fully liquid (phase == 1).
For example, consider a material that starts melting at 305 K and finishes at 320 K. If the temperature is 310 K, it is within the range, but if ‘phase’== 0’ or ‘phase == 1’, the material is not currently undergoing a phase change. Conversely, if ‘phase’ is between 0 and 1 but the temperature is outside 305-320 K, the phase change should not be active.
So, the code should be modified as follows.
if T >= Tmelt_start && T <= Tmelt_end && phase < 1 && phase > 0
phaseChangeRate == {0.001, '1/s'};
else
phaseChangeRate == {0, '1/s'};
end
I hope this helps.

类别

Help CenterFile Exchange 中查找有关 Elements 的更多信息

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by