ModelCenter Example

This example shows you how to use ModelCenter to validate a model created in Ansys SAM.

To begin using the sample project, complete these steps:
  1. 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.
  2. 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.
    1. Right-click the Bicycle root package and choose Import Library.
    2. Click Standard Libraries to expand the drop-down.
    3. 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.
  1. In the Bike block diagram (Definition package > Diagrams package > Bike diagram), find the part-definition for the Frame and click the Weight attribute.
  2. In the Properties panel, on the Value line, enter 2, and click the drop-down and select kg. Then change the Definition to real.
    Continue adding weights for the parts as follows:
    • Tire: 2 kg
    • Rim: 1 kg
    • Wheel: 3 kg
    • Bike: 15 kg
  3. Repeat the previous two steps for all structural element usages in the block diagram Bike.
Now open the model in ModelCenter.
  1. 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.
  2. 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.
  1. Click the New file icon located under the ModelCenter File menu and select New Analysis....
    The Analysis Editor opens. Notice that the Bicycle 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.
  1. 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()); 
    }
  2. 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.
  3. In the Systems Model Structure, expand the model to Usage > Structure > bike > frontWheel, then expand frontWheel, rim, and tire.
  4. For frontWheel, click weight and drag to the Analysis Variables panel, to sum.
    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.
  5. 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.
  6. 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.
  1. Under the ModelCenter File menu, click the New file icon and select New Analysis....
  2. For writing a script, in the Analysis Editor, under Analysis Type, select Script Analysis.
  3. In Analysis Selection, click the Edit button.
    The Script Editor opens.
  4. 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
                    
  5. In the Variables panel, add BikeWeight and define it as Output from the drop-down list.
    Repeat this for the variables IsSatisfied and Margin. Then repeat the step to define the following variables as Input.
    • UpperMargin
    • frontWheelWeight
    • rearWheelWeight
    • frameWeight
  6. Change the type of IsSatisfied to Boolean. Make sure all the other created variables are type double.
  7. Click OK to save your work and close the editor.
  8. 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.
  1. Under the System Model Structure tab, expand the Bicycle model to Usage > Structure > Bike, then expand the bike parts Frame, frontWheel, and rearWheel.
  2. 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
  3. 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
  4. In the Analysis Variables panel, click UpperMargin and in the Set Constant Value text field, enter 8 and click the green check mark.
  5. Click the OK button.
Now add all analysis scripts to the execution plan.
  1. The Analyses List lists the three analysis scripts. Drag and drop each of these to the Analyses panel.
  2. Click the disk icon to save your file.
Verify the requirement by running your script.
  1. 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.
  2. Optional: Click the disk icon to save your result.
You can change the values and try another validation.
  1. In the Structure Elements panel, for the front wheel, change the tire weight from 2 to 1.5.
  2. For the rear wheel, change the tire weight from 2 to 1.
  3. 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.
  4. Click the disk icon to save your successful design and execution plan.
  5. Return to Ansys SAM.
    In the project tree, a ModelCenter folder has been added. It contains the analysis from above.
  6. Click the folder and subfolders to see the scripts, analyses, and results.
Save as new baseline
  1. 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.