How to force a Beginning Value in Simscape

9 views (last 30 days)
Gerrit
Gerrit on 19 Aug 2020
Commented: Gerrit on 19 Oct 2020
In many blocks of Simscape, for example the Constant Volume Chamber (G) block, the user can specify a number of initial or Beginning Values for the blocks variables or states. The Simscape Solver then decides whether to override that value when the Simulink simulation is run. The user can specify a priority for the Beginning Value, with options High, Low or None. However, even with the Priority set to High, the Solver sometimes modifies the initial values from the specified Beginning Value. Note: this happens even when I untick the 'Start simulation from steady state' box in the Solver Configuration menu.
Thus, is there a way to really force the use of the Beginning Value as the actual initial value of the variable in the block? Or is there a recognised alternative to the standard Constant Volume Chamber (G) block in these circumstances?
As background: The example that I am working on is a bottle of gas with a fixed volume (the 'Constant Volume Chamber (G)' block) where the gas outflow is determined (partly) by the initial gas pressure and temperature of the gas in the bottle. Therefore, I really need those values to be exactly as I specify them. In a small development model this all works fine. However, when I integrate the bottle with its connected tubes and valves in a larger network, Simscape keeps changing the inital pressure. I know that some of the initial values in other parts of the overall Simscape model are way off steady-state conditions (there are warning messages about that in the diagnostics), so that may be part of the problem. However, it is quite a challenge to calculate the (or even just a closer) full steady state of this system, with given boundary conditions and selected initial conditions, in MATLAB.
  2 Comments
Lyes Lyes
Lyes Lyes on 19 Oct 2020
Hello, I have the same problem, except that for my part it is the initial air temperature of a room, which will be exposed to heating, after a certain time the temperature converges well but what bothers me is The initial state? Even if I impose the condition and to put it high, low, it doesn't work at all ?
Gerrit
Gerrit on 19 Oct 2020
As a solution that may work for some: in my specific case the temperature in the bottle was (assumed to be) constant. With that restriction and the Ideal Gas Law, I was able to formulate a hybrid Simulink/Simscape bottle model to replace my Simscape 'Constant Volume Chamber (G)' block:
Here, the top-right purple signal, from the B port of the sensor, links to the rest of the system.
The desired initial pressure is now specified in 'Bottle Pressure (G)'.
The gain in 'density flow [kg/m^3/s]' is '-1/bottle_volume' (the '-' represents that flow is out of the bottle) and the gain in 'temp*dens flow [Kkg/m^3/s]' is 'bottle_temperature'; 'Rng' is the mass-specific ideal gas constant, for natural gas in my case.
In its current form, this model is subject to the temperature being constant. It could be extended to use a given time-varying temperature by replacing the constant temperatures of 'Bottle Temp [K]' and 'temp*dens flow [Kkg/m^3/s]' with a time-varying temperature. You need to ensure that both temperatures (inputs) are the same. The 'Gain' 'temp*dens flow [Kkg/m^3/s]' needs to be replaced by a 'Product' with the temperature as its second input.
Can this be extended further to have a heat input? I think so, if you replace the constant/given temperature by a calculation from the energy balance of the room plus the thermodynamic temperature-energy relation (using specific heat of air). That adds another layer of complexity, but should be possible. I assume that you have a definition of what your heating is (constant or depending o other variables).

Sign in to comment.

Answers (0)

Categories

Find more on Gas Library 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!