1
votes

I am currently doing a course called "Modeling of dynamic systems" and have been given the task of modeling a warm water tank in modelica with a distributed temperature description.

Most of the tasks have gone well, and my group is left with the task of introducing the heat flux due to buoyancy effects into the model. Here is where we get stuck.

the equation given is this: Given PDE

But how do we discretize this into something we can use in modelica?

The discretized version we ended up with was this:

(Qd_pp_b[k+1] - Qd_pp_b[k]) / h_dz = -K_b *(T[k+1] - 2 * T[k] + T[k-1]) / h_dz^2

where Qd_pp_b is the left-hand side variable, ie the heat flux, k is the current slice of the tank and T is the temperature in the slices.

Are we on the right path? or completely wrong?

1

1 Answers

2
votes

This doesn't seem to be a differential equation (as is) so this does not make sense without surrounding problem. For the second derivative you should always create auxiliary variables and for each partial derivative a separate equation. I added dummy values for parameters and dummy equations for T[k]. This can be simulated, is this about what you expected?

model test
  constant Integer n = 10;
  Real[n] Qd_pp_b;
  Real[n] dT;
  Real[n] T;
  parameter Real K_b = 1;
equation
    for k in 1:n loop
      der(Qd_pp_b[k]) = -K_b *der(dT[k]);
      der(T[k]) = dT[k];
      T[k] = sin(time+k);
    end for;
end test;