ModelCenter Example
This example shows you how to use ModelCenter to validate a model created in Ansys SAM.
-
In Ansys SAM, open the
Bicycle
model you created (the steps are described in Prerequisites).Explore the structure tree and its Definition packages, Usage packages, and diagrams.Open Usage package > Diagrams package > bike diagram. Note that the bike usage contains the parts of the bicycle, each with its own weight. The bike itself has the combined weight of the parts. In addition, the model includes a requirement for the maximum bicycle weight,less than 8 Kg
in the example. -
Import the SI Unit library.
The SI Unit library is based on the international systems. You will use it to assign units to the bicycle parts.
- Right-click the Bicycle root package and choose Import Library.
- Click Standard Libraries to expand the drop-down.
- Select SI, then click the Import button.
Import SI appears at the top level of the Project list.
Next you will assign units and values to the bicyle parts.
- In the Bike block diagram (Definition package > Diagrams package > Bike diagram), find the part-definition for the Frame and click the Weight attribute.
-
In the Properties panel, on the
Value line, enter
2
, and click the drop-down and selectkg
. Then change the Definition toreal
.Continue adding weights for the parts as follows:- Tire: 2 kg
- Rim: 1 kg
- Wheel: 3 kg
- Bike: 15 kg
- Repeat the previous two steps for all structural element usages in the block diagram Bike.
Now open the model in ModelCenter.
-
Select File >
Open in ModelCenter.
ModelCenter opens. Under Systems Model Structure you see the
Bicycle
project. In the Requirements List, you see the project Weight requirement. -
Expand
Bicycle
to load the model structure.
Next connect the System Architecture Model to simple ModelCenter analyses
to compute the weights of the bicycle frame and each wheel.
-
Click the
New file
icon located under the ModelCenter File menu and select New Analysis....The Analysis Editor opens. Notice that theBicycle
project appears in the Map Analysis Variables window in the Systems Model Structure tab. You can click it to expand it.
For the weight analysis, a ModelCenter script wrapper that calculates the
sum of two variables is required.
-
To create the wrapper, copy the following code and paste it to an empty file
using a text editor such as Notepad. In your preferred ModelCenter Remote
Execution (MCRE) Analysis path (MCRE >
Configure > Directories
> Analyses Path), save the file as
SumTwo.scriptWrapper
.variable: x1 double input variable: x2 double input variable: sum double output script: language="java" void run() { sum.setValue(x1.getValue() + x2.getValue()); } -
In the Server Browser window, select
SumTwo
from the folder where you saved it and double-click it.When you double-click it, you see its variables appear in the Analysis Editor in the AnalysisVariables panel. You can now connect the system architecture model to the script. -
In the Systems Model Structure, expand the model to
Usage
>Structure
>bike
>frontWheel
, then expandfrontWheel
,rim
, andtire
. -
For
frontWheel
, click weight and drag to the Analysis Variables panel, tosum
.This links frontWheel.weight to the output of the SumTwo analysis.Repeat this step for the rim.weight to x1 and tire.weight to x2. This links the rim and tire weights to the two inputs of the SumTwo analysis. -
Enter a name for your analysis (such as
frontWheelWeight
) in the Analysis Name text field below Analysis Variables and click OK.In ModelCenter,frontWheel
analysis is listed in the Analyses List panel. -
Repeat steps 12-14 for the rear wheel and give your analysis the name
RearWheelWeight
.
Next, create a simple script to analyze the requirement and determine
whether the bicycle model meets it. The script computes the bicycle weight and
compares the computed weight to the weight requirement.
-
Under the ModelCenter File menu, click the
New file
icon and select New Analysis.... - For writing a script, in the Analysis Editor, under Analysis Type, select Script Analysis.
-
In Analysis Selection, click the
Edit button.
The Script Editor opens.
-
In the Script panel, replace the default script with the
following script.
sub run BikeWeight = frontWheelWeight + rearWheelWeight + frameWeight IsSatisfied = BikeWeight < UpperMargin Margin = UpperMargin - BikeWeight end sub -
In the Variables panel, add
BikeWeight
and define it as Output from the drop-down list.Repeat this for the variablesIsSatisfied
andMargin
. Then repeat the step to define the following variables as Input.- UpperMargin
- frontWheelWeight
- rearWheelWeight
- frameWeight
- Change the type of IsSatisfied to Boolean. Make sure all the other created variables are type double.
- Click OK to save your work and close the editor.
-
Back in the Analysis Editor, in the Analysis Variables
panel, the list of variables appears. Enter a name for your script, such as
BikeWeightReq
.
Next, link the variables in the analysis to the system architecture
model.
-
Under the System Model Structure tab, expand the
Bicycle
model toUsage
>Structure
>Bike
, then expand the bike partsFrame
,frontWheel
, andrearWheel
. -
Now connect the
weight
for each part to the corresponding variable in Analysis Variables.- Bike.weight to
BikeWeight
- frame.weight to
FrameWeight
- frontWheel.weight to
FrontWheelWeight
- rearWheel.weight to
RearWheelWeight
- Bike.weight to
-
Now click the Requirements List tab and connect the
requirement usage
weight
(lower-case) to the corresponding variables in Analysis Variables.- Is Satisfied to
IsSatisfied
- Margin to
Margin
- Is Satisfied to
-
In the Analysis Variables panel, click
UpperMargin
and in the Set Constant Value text field, enter8
and click the green check mark. - Click the OK button.
Now add all analysis scripts to the execution plan.
- The Analyses List lists the three analysis scripts. Drag and drop each of these to the Analyses panel.
- Click the disk icon to save your file.
Verify the requirement by running your script.
-
To run the analysis script, click the green
Play
icon.The results are listed in the Requirements panel at the bottom. A red X indicates the requirement is not satisfied for the defined values. - Optional: Click the disk icon to save your result.
You can change the values and try another validation.
- In the Structure Elements panel, for the front wheel, change the tire weight from 2 to 1.5.
- For the rear wheel, change the tire weight from 2 to 1.
-
Click the green
Play
icon.This time, a green check mark appears in the Satisfied column. Your model has passed validation, and the passing margin is listed in the Margin column. - Click the disk icon to save your successful design and execution plan.
-
Return to Ansys SAM.
In the project tree, a
ModelCenter
folder has been added. It contains the analysis from above. - Click the folder and subfolders to see the scripts, analyses, and results.
Save as new baseline
-
In the Results tab, right-click the structural element
bike
and select Save Baseline Values.Verify that the weight value attributes are updated in Ansys SAM.