Skip to main content

Beam Moment Iterator using ESA_XML

The ‘Beam Moment Iterator using ESA_XML’ is a simple script written in Windows PowerShell which illustrates the use of ESA_XML.

The ‘Beam Moment Iterator using ESA_XML’ is a simple script written in Windows PowerShell which illustrates the use of ESA_XML. By means of an example the script shows how SCIA Engineer can be run iteratively while each time changing the inputs based on the results of the previous iteration step.

Prerequisites

The project file was saved using SCIA Engineer version 18.0
The PowerShell script was written using PS version 5.1 under Windows 10

Introduction

The ‘Beam Moment Iterator’ is a simple script written in Windows PowerShell which illustrates the use of ESA_XML. By means of an example the script shows how SCIA Engineer can be run iteratively while each time changing the inputs based on the results of the previous iteration step.
PowerShell was used since it has native XML support and is available by default in Windows 10.

The following example is used:

A beam on 2 supports is loaded by a line load.
The goal is to set an initial value for the line load and perform a linear calculation, then return the bending moment caused by this line load.
The line load is then modified and the whole process repeated until the bending moment exceeds a given value.

The archive containing the Beam Moment Iterator contains the following files:

  • Beam.esa           => The project file containing the above use case
  • Beam.xml           => The XML export of the line load, exported from SCIA Engineer
  • Beam.xml.def     => The XML export definition of the line load, exported from SCIA Engineer
  • XML_Script.ps1 => The PowerShell script

All files should be extracted in the same folder. To see both the script and the output together it’s advised to use the PowerShell ISE.

Description of the Script

Part 1: Inputs

The first lines of the script are used to define the inputs: the maximal moment to be reached, the initial value of the lineload and the increment by which the lineload should be increased in each step.
Note that all values are defined in basic SI units for XML (so Nm and N/m). The lineload is set as negative to obtain a positive bending moment in the beam.
In addition to these parameters the path to SCIA Engineer should be defined here since this is needed to run ESA_XML.
In essence this is the only part of the script where changes should be made.

Part 2: Defining files

This part determines the actual path and assigns the different files to variables.

Part 3: Reading Input XML

The content of the Beam.xml file is read and stored in a variable.
The iteration step is initialized to 1.

Part 4: Modifying the input

The iteration step starts by storing the defined lineload value into the XML object. This object is then saved as an actual XML file.
Using this ‘temporary’ XML file the original Beam.xml remains unchanged.

Part 5: Running ESA_XML

Using ESA_XML the project file is updated with the lineload value and a linear calculation is run.
After this calculation the RESULTS XML I/O document is updated and exported into an XML file.
(For more information on the ESA_XML syntax reference is made to the SCIA Engineer WebHelp)

Part 6: Waiting for- and reading of results

The script needs to wait until the results file appears before continuing.
When the results are available, the content of the XML file is stored in a variable and the bending moment is read from this output.

Part 7: Cleanup and loop

The final part of the iteration cleans up temporary files and prints the output of the given iteration.
The lineload and iteration step get incremented and the bending moment is compared with the maximal value defined at the start.
In case the bending moment of the current iteration is smaller than the maximal value, the iteration continues.

Sample Output

The following provides a sample output of the script when using the default parameters:

The loop ends after 5 steps since the moment of 28125 Nm exceeds the limit of 25000 Nm.