Simscape Inheritance - Parameters as structs or objects
显示 更早的评论
Problem:
I would like to use custom structs or objects to override built-in simscape component parameters, eventually via a drop down menu (with enums).
Note, I have started by using the following documenation as a baseline. My issue seems to be with defining simscape parameters as structs or objects: https://www.mathworks.com/help/simscape/lang/subclassing-and-inheritance.html
I am trying to override the foundation.thermal_liquid.utilities.thermal_liquid_settings to essentially add my own drop down list of fluids, similar to how foundation.thermal_liquid.utilities.thermal_liquid_properties works.
I have created a namespace for all of my fluids (+fuels).
Desired Behavior:
Interface similar to foundation.thermal_liquid.utilities.thermal_liquid properties, with my own predefined fluids. My implementation works fine it users manually fill in all of the Thermal Liquid Settings parameters with the appropriate fluid.<field> and units; however, I would like to remove this step and allow them to be directly selected from a drop down menu with the rest of the implementation handled behind the scenes.
Attempted Implementation:
In my +fuels namespace, I have functions which create a structure containing the various tables required by thermal_liquid settings. As the simplest example, assume that fluid.my_fluid returns the following:
fluid = fuels.my_fluid % calling my function
>>> fluid =
struct with fields:
t_vect: [1 2 3 4 5]
I try to override these with the following:
component fuelprops < foundation.thermal_liquid.utilities.thermal_liquid_settings(...
T_TLU = {fluid.t_vect, 'K'})
parameters
fluid = fuels.my_fluid;
end
end
When I run ssc_build() on the namespace containing my fuelprops component, I recieve the following error:
No function or value named fluid.t_vect.
I initially thought this might be due to the fact that structs do not necessarily have certain fields, so I tried another implementation with an object which has the property t_vect
classdef MyFluid
properties
t_vect = [1:5]
end
methods
function self = MyFluid()
end
end
end
With this implementation, I recieve the below error:
No function or value named fluid.t_vect
Again, this issue persists even if I create a method "t_vect" which returns the desired array.
Is there any way to setup Simscape Components to take in objects or structs which override parameters from inheritent components? I full expect the above example to error as [1:5] is not a valid value for T_TLU; however, the value I am entering seems to never been seen.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!