カスタム コンポーネント
カスタム コンポーネントを表す Simscape™ ファイルの作成
Simscape 言語では、パラメーター化、物理的接続、基となる方程式のすべて備わったテキスト ファイルとしてカスタム コンポーネントを定義できます。このページの各トピックでは、コンポーネントのパラメーター、変数、および接続の宣言に関する詳細情報を提供しています。カスタム コンポーネントの定義に関する他の側面については、方程式、離散イベントおよびモード チャート、および合成コンポーネントを参照してください。
カスタム コンポーネントの作成を始めるには、カスタム コンポーネントの作成を参照してください。ここでは、一般的なワークフローの概要を説明しています。このページ下部の「参照アプリケーション コンポーネント」の下にあるトピックでは、完全なコンポーネント例を提供し、それぞれの例で使用されている手法を詳細に説明しています。
言語構文
annotations | Control appearance of Simscape block based on the component |
branches | コンポーネントのスルー変数とノード間の関係を確立する |
component | Component model class definition |
Faults | Faults interface annotation for custom component (R2024b 以降) |
inputs | Define component inputs, that is, physical signal input ports of block |
nodes | Define component nodes, that is, conserving ports of block |
outputs | Define component outputs, that is, physical signal output ports of block |
parameters | ドメインまたはコンポーネントのパラメーターを宣言する |
variables | Declare domain or component variables |
トピック
基本的な手法
- カスタム コンポーネントの作成
コンポーネントの種類、ファイル構造、ワークフローの概要。 - Attribute Lists
Model attributes and member attributes used in Simscape language.
宣言と分岐
- Declaring Domains and Components
Declaration section of domain and component files: purpose, definitions, rules, member summaries. - バネ コンポーネントの宣言
次の図は、機械回転ドメインにおける 4 つのコンポーネント (質量、バネ、ダンパー、および参照) からなるマス-バネ-ダンパー システムのネットワーク表現を示しています。 - Declare Component Parameters
Component parameters let you specify adjustable parameters for the Simscape block generated from the component file. - Declare Component Nodes
Component nodes define the conserving ports of a Simscape block generated from the component file. - コンポーネントの入出力の宣言
保存端子に加え、Simscape ブロックには物理信号の入力端子および出力端子を含めることができます。 - Declare Component Variables
When you declare Through and Across variables in a component, you are essentially creating instances of domain Through and Across variables. - Define Relationship Between Component Variables and Nodes
How to connect Through and Across variables declared in a component file to the domain Through and Across variables. - Declaration Functions
Use MATLAB® functions to compute derived parameter values or initialize variables.
コンポーネント バリアント
- Defining Component Variants
Use conditional sections to define variants within component file. - Defining Conditional Visibility of Component Members
Use annotation section to define conditional visibility of ports and parameters for component variants.
高度な手法
- Enumerations
Specify a discrete set of acceptable values for parameters and event variables. - Subclassing and Inheritance
Subclassing allows you to build component models based on other component models by extension. - Fault Annotations
Use theannotationssection of a component file to model faults in a custom component.
参照アプリケーション コンポーネント
- Simscape 言語での線形抵抗のモデル化
線形抵抗を例として使用した、Simscape 言語でのモデル化の仕組みの概要。 - 機械コンポーネント — バネ
次のファイルspring.sscでは、springという名前のコンポーネントを実装します。 - 電気コンポーネント — 理想的なコンデンサ
次のファイルideal_capacitor.sscでは、ideal_capacitorという名前のコンポーネントを実装します。 - No-Flow Component — Voltage Sensor
The following file,voltage_sensor.ssc, implements a component calledvoltage_sensor. - Grounding Component — Electrical Reference
The easiest way to implement a grounding component is to use a connection to an implicit reference node. - Composite Component — DC Motor
This example shows how to implement a DC motor model by means of a composite component. - Composite Component with Equations — RMS Voltage Sensor
TheVoltageSensorRMScomponent implements a voltage sensor that measures the root mean square (RMS) value of AC voltage between two electrical nodes. - Triggered Delay Component
This example shows how to implement a triggered delay component. - Enabled Component
This example shows how to implement a component similar to a Simulink® enabled subsystem. - ヒステリシスをもつスイッチ
この例では、モード チャートと列挙を使用してコンポーネントをモデル化する方法を示します。 - コンポーネント バリアント — 直列 RLC 分岐
この例では、条件セクションを使用して、コンポーネント ファイル内にバリアントを実装する方法を示します。 - Component Variants — Thermal Resistor
This example shows how to implement conditional visibility of component ports, parameters, variables, and a conditional custom block icon.