-
Notifications
You must be signed in to change notification settings - Fork 70
Simulation stability #89
Comments
You are right, right now the user has to select the right time-step. I think, this instabilities that you showed us, are more related to stability regions of the RK than to Courant condition, but anyway, it's something we must deal with carefully. Moreover, at some point we would like to try other schemes (ie. Adams-Bashforth) that I have seen they use in other simulators. It would be great to be able to do some numerical research on the integration of this and future systems. |
I'm afraid you are probably wrong, basically because you have a lot of explicit integrations in your model. The first explicit scheme results from the decoupling of the Momentum and kinematic equations, at But that's not the very only place where you are actually using a explicit scheme. In fact, the forces are computed (sampled) just once by time step, regardless the internal changes of speed and position (as far as I know). Hence, you can improve your internal integration scheme as many as you want... Right now, if you are not able to introduce a Courant condition your system would become unstable. Anyway, since your integration is explicit, I also would choice an Adams-Basforth instead of a Runge-Kutta. |
We still have some problems with numerical stability even if every object is updated at each internal time step. Maybe this is not well implemented or maybe we need to tune some of the internal parameters of the method. Moreover, it seems that there is a problem with the conversion from This is a working example: from pyfme.aircrafts import Cessna172
from pyfme.environment.atmosphere import ISA1976
from pyfme.environment.wind import NoWind
from pyfme.environment.gravity import VerticalConstant
from pyfme.environment import Environment
from pyfme.utils.trimmer import steady_state_trim
from pyfme.models.state.position import EarthPosition
from pyfme.models import EulerFlatEarth
from pyfme.utils.input_generator import Constant, Doublet
from pyfme.simulator import Simulation
aircraft = Cessna172()
atmosphere = ISA1976()
gravity = VerticalConstant()
wind = NoWind()
environment = Environment(atmosphere, gravity, wind)
pos = EarthPosition(x=0, y=0, height=1000)
psi = 0.5 # rad
TAS = 45 # m/s
controls0 = {'delta_elevator': 0, 'delta_aileron': 0, 'delta_rudder': 0, 'delta_t': 0.5}
trimmed_state, trimmed_controls = steady_state_trim(
aircraft,
environment,
pos,
psi,
TAS,
controls0
)
system = EulerFlatEarth(t0=0, full_state=trimmed_state)
de0 = trimmed_controls['delta_elevator']
controls = controls = {
'delta_elevator': Doublet(t_init=2, T=1, A=0.1, offset=de0),
'delta_aileron': Constant(trimmed_controls['delta_aileron']),
'delta_rudder': Constant(trimmed_controls['delta_rudder']),
'delta_t': Constant(trimmed_controls['delta_t'])
}
sim = Simulation(aircraft, system, environment, controls, dt=0.3)
results_03 = sim.propagate(25)
sim = Simulation(aircraft, system, environment, controls, dt=0.05)
results_005 = sim.propagate(25)
kwargs = {'subplots': True,
'sharex': True,
'figsize': (12, 100)}
ax = results_005.plot(marker='.', color='r', **kwargs)
ax = results_03.plot(ax=ax, marker='x', color='k', ls='', **kwargs)
plt.show() These are the outputs: |
I certainly don't know nothing about the Anyway, these plots show the relevance of the time step. I thought a bit about that, and I think you'll pass a really hard time to get an actual Courant condition. However, you can simplify a bit the things featuring your airplane natural frequencies (by a decay test, maybe?), and then setting the time step as a fraction of the minimum resulting natural period. Think about that and let's start discussing |
The I like your approach, @sanguinariojoe. I was thinking about setting the On the other hand there is still something that intrigues me: ** This is done in: What
That besides that ugly |
The flow is a bit difficult to follow and I would need some time and pen and paper to figure out an answer to this :) Give me some days and I'll try to think something, if you haven't found the problem yet. |
It was related to the position array dtype, solved in: 8dd95a8 |
Right now the simulation stability completely rests on the user's selected time step. For instance, let's reduce the time step in example_005.ipynb just replacing
N = tfin * 100 + 1
by
N = tfin * 10 + 1
and enjoy the arising instabilities at the end of the simulation (you may also increase
tfin
to 200 seconds if you wanna crash your plane :-) )I don't know much about flight dynamics, but probably a Courant condition can be optionally imposed. Right?
The text was updated successfully, but these errors were encountered: