I’m developing a model to describe the behavior of a two-pipe network. The network is connected to a tank where heat is injected or extracted from the system depending on external mass flow rates. The mass flow rates for both heating and cooling are arbitrarily assumed to vary over time.
The initial value of PipeTemp is associated with the parameter StartTemp. However, at different time points PipeTemp is computed from a max function.
The problem is that because the variable PipeTemp depends on other time varying variables that are computed using the value of PipeTemp, Dymola terminates the simulation and produces the following error: Failed to solve nonlinear system using Newton solver.
This simple model can be easily simulated in Excel because it’s capable of handling interdependency between cell variables. What could be the workaround for this model in Dymola in order to avoid the nonlinear system of equations?
model FullyMixedTemperature
parameter Real StartTemp = 20; //Assumed mixed temperature in the pipes
parameter Real dTpipe = 10; //Temperature difference between the two pipes
parameter Real TankVol = 150; //Total volume
Real DecreasingTemp; //Mixed temperature in the pipe due to additional cooling mass flow rate
Real IncreasingTemp; //Mixed temperature in the pipe due to additional heating mass flow rate
Real PipeTemp(start=StartTemp); //Mixed temperature in the pipe
Real CoolFlowRate; //Additional cooling flow rate from external sources
Real HeatFlowRate; //Additional heating flow rate from external sources
equation
CoolFlowRate=0.5*time;
HeatFlowRate=2*time;
PipeTemp = max(DecreasingTemp, IncreasingTemp);
DecreasingTemp= PipeTemp-(dTpipe*CoolFlowRate/TankVol);
IncreasingTemp= PipeTemp+(dTpipe*HeatFlowRate/TankVol);
end FullyMixedTemperature;