Dynamic script which creates and deletes parts over time
Show older comments
Dear all,
I wrote a function CoolingCalc that calculates the cooling of a porous material based on the input conditions. I want to simulate adding material into a tank at a certain rate per second (m_in). If CoolingCalc represents a "block" containing m_in material per second, then the total cooling at a given time should be the sum of the cooling from all blocks, considering that blocks were also added earlier.
Additionally, if I set a total mass Mass_setpoint after which I start removing material from the tank, I would need a script that adds CoolingCalc blocks until their combined mass reaches Mass_setpoint, and then begins removing the earliest blocks that were created.
My understanding is that this requires a dynamic script that creates and deletes these blocks over time.
Is it possible to implement this in MATLAB?
I am grateful for any help you can provide.
Best regards,
clear; clc
t_cycle = 200; % [s] simulation time
T = 303.15; % [K] temperature
P = 1; % [MPa] pressure
% Material related
m_in = 0.001; % [kg/s] inlet flowrate
Mass_setpoint = 0.1; % [kg] set point after which material is removed
m_out = 0.002; % [kg/s] outlet flowrate
Xs = 0.002; % [m^3/kg] Pore volume of material
Q_st = 450; % [kJ/kg] Isosteric heat of material
Xeq0 = 1; % Initial value of X
% Plot
[Q_cooling] = CoolingCalc(T, P, Q_st, Xs, Xeq0, m_in, t_cycle);
plot(Q_cooling)
hold on
Accepted Answer
More Answers (0)
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!