- Have its own Model Workspace where you could store local data
- Be capable of running as a standalone simulation
Libraries, model workspace, base workspace and how to parameterize my models
5 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I am building a library (with sublibraries) of models that will eventually be used as parts in simulations of industrial equipment.
Although it is not exactly this way, let us consider this hierarchy:
Library/
* Motors/
* -- Diesel_A31
* -- Diesel_A32
* Powertrains/
* -- PT03
* -- PT10
Now the question is that every model should be able to run independently, but all the models make use of constants such as for example:
- Gravity (both for motors and powertrains)
- Themodynamical properties from air in normal conditions (only for motors, nor for Powertrains)
and parameters, like:
- Air temperature (both for motors and powertrains the same), would be a "whole simulation" parameter
- Horsepower (only for motors, for every motor potentially different, for every instance of the model the same)
- Initial position of the cilinder (only for motors, for every instance different)
Now the question is how do I manage and store all this information in the library and the models that reside inside each library or sub-library.
- Global workspace? Please no
- Model workspace? It looks like my models haven't got a model workspace, maybe since they are in a library
- Mask parameters? I would rather be able to write them down in a text file where I could explain the meaning of each parameter. The number of parameters is too high anyway. I think that the initial position of the cilinder could be a mask parameter.
And would it be possible to make the parameters accesible to the model without the user actually intervining? I try to keep in mind that the model should be able to work independently without the user having to look under the mask or perform any action.
Even though the problem is not very clear either to me, I hope I was able to state the question clearly.
Any help or experience in this regard would be greatly appreciated.
Carlos.
0 个评论
采纳的回答
Jarrod Rivituso
2011-5-6
Hi Carlos,
Is there any specific reason you have decided on using libraries for this? It sounds like you'd have a much easier time using model references.
With model references, each component (Diesel_A31, Diesel_A32, PT03, etc.) would be it's own separate model. This means each component would
If you use subsystems stored in libraries for these components, then the only local workspace those subsystems have for parameters is the Mask Workspace.
What's very nice about the Model Workspace over the Mask Workspace is that you can define either a MAT-file or a MATLAB script as the data source for the Model Workspace. So, you could write all your parameters for a given component in a MATLAB script and then tell the Model Workspace to use that MATLAB script as its data source.
Does that make sense?
0 个评论
更多回答(2 个)
Kaustubha Govind
2011-5-9
I am partial to the Mask Parameters option, because it doesn't pollute the Model Workspace and allowing the blocks to run independently. Why not simply return all the parameters from a shared MATLAB function, and run that function in the Mask Initialization? I guess the downside is that each block will have its own copy of the data, but I also think of it as an advantage, because the block has complete control over its data.
Alternatively, you could assign the parameter values directly in the Model Workspace from the block mask (you could check if the variable already exists before attempting to define a parameter) - but this is roundabout and not transparent to the user, since most people tend not to examine the model workspace and could potentially define conflicting parameters in the base workspace (which are always overrided by the model workspace variables, causing confusion).
0 个评论
Carlos Martinez
2011-5-10
1 个评论
Jarrod Rivituso
2011-5-20
For the "really constant" stuff, I would use parameters in the base workspace (it is, after all, a workspace that can be accessed by all models).
For the external temperature - if it really does vary a lot during the simulation then I would consider adding it as an input signal to the models that require it.
Hope this helps!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Powertrain Reference Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!