MATLAB: Fixed-step solvers, model referencing and Normal and Accelerator mode

simulinksolvers reference modeling

Dear all,
I'm designing a Simulink model to simulate the dynamics of a vehicle. My model is composed by a system "VehicleDynamics" which contains two referenced models "WheelDynamics" (4 instances) and "LocalController" (4 instances). The model "WheelDynamics" include a continuous-time state, while the model "LocalController" just include some gains and switches, but it takes the wheel speed as an input signal and it generates a continuous-time output. My model "VehicleDynamics" runs in normal mode, the model "WheelDynmaicsFL" (FL stands for front-left) runs also in Normal mode, while the other three instances "WheelDynmaicsXX" (where XX is FR,RL,RR) run in Accelerator mode. The same is for the four instances of "LocalControllerXX": "LocalControllerFL" runs in Normal Mode, while the other three instances of the same model runs in Accelerator mode. Until here, everything works fine as long as I use a variable-step solver. If I use a fixed-step solver (like for example ode3 (Bogacki-Shampine)), I get this error:
"The Model block cannot inherit a continuous sample time. Output port 1 of Model block 'SingleWheelTEST/LocalCtrlFL' cannot accept 'continuous' sample time."
To get a better understanding of the system, I made a model with just one instance of "WheelDynamics" and "LocalController" that run in Normal mode. With the fixed step solver I still experience the same error, while with the variable-step solver everything goes smooth, and I cannot understand why!
I already tried to configure all the models in question "SingleWheelTEST", "WheelDynamics" and "LocalController" to use a Fixed-Step solver, but it didn't worked out.
Fianlly, having 4 instances of "WheelDynamics" and "LocalController", it seems that I'm constrainted to use Accelerator mode on 3 of the instances. However, I don't want to use them because Simulink generates code in the working folder that put additional files that I will never open (it creates like a "slprj" foldes and several .mexw32 files that I don't want). Is it possible to use all in Normal mode instead?
The Matlab version I'm using is the 2009a.
Thanks,
Ubaldo

Best Answer

Hi!
I think we are close to the solution! In what follows I performed all the simulations by using the fixed-step solver Ode3(Bogacki-Shampine) to all the models. Moreover, let me say that the model 'SingleWheelTEST/LocalCtrlFL' is composed by 4 input ports, 1 output port, 2 gains, one switch, one product block and one scope(so the model is very simple, I would even upload an image but I do not know if it is possible here in the forum).
Anyway, I tried to put a sample time "0" to a randomly chosen block in the 'SingleWheelTEST/LocalCtrlFL' model (for instance, I set sample time "0" to an Inport). I tried to run the simulation and I got this error
"Root Inport 'LocalController/Is Braking' has a sample time of [0 0] which does not match the sample time [0.4 0] of its destination: input port 1 of block 'LocalController/Scope'. Root inports must have the same sample time as their destinations for model reference. Please correct this situation by changing one of the two sample times or inserting a Rate Transition block. This error message is related to a hidden Inport block."
So I argued that the problem is in the Scope block. In addition, I don't want to add additional blocks in the model (otherwise is not the same model as in the case with variable-step solver, where everything works fine without additional blocks.) Then, with the same setting as above (i.e. sample time "0" to an Inport), I removed the Scope block and this time everything worked out perfectly, but with these warnings:
"Warning: Unable to determine a fixed step size based on the sample times in the model 'SingleWheelTEST', because the model does not have any discrete sample times. Picking a fixed step size of (0.4) based on simulation start and stop times. You can disable this diagnostic by explicitly specifying a fixed step size in the Solver pane of the Configuration Parameters dialog box, or setting the 'Automatic solver parameter selection' diagnostic to 'none' in the Solver group on the Diagnostics pane of the Configuration Parameters dialog box.
Warning: The model 'SingleWheelTEST' has continuous states and is referencing (via the Model block 'SingleWheelTEST/LocalCtrlFL') the fixed-step model 'LocalController' which has blocks with continuous sample time. The solver 'ode3' used to simulate model 'SingleWheelTEST', will execute the referenced model 'LocalController' in minor time steps, where as during standalone simulation the model 'LocalController' uses a discrete solver which does not have minor time steps. This can cause results from the Model block and results obtained from standalone simulation of the referenced model to be different. You can disable this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog."
Honestly, I was surprised that the problem could be the Scope block. Could you please explain me what happened with that block? And could you also tell me more about the warnings I get?
Finally, just for the sake of completeness, I also tried to run a simulation by setting sample time "-1" to all the blocks in 'SingleWheelTEST/LocalCtrlFL'and by deleting the Scope block. The result is that the sample time of this referenced model became again Discrete1 0.4.
I wonder what trick the variable-step solvers use to adapt all the sample times of all the blocks...