# Spring Example

## Contents

# Problem Introduction and Definition

An engine uses compression springs to open and close valves, using the camshaft. The usual spring stiffness, , of this type of spring is 20,000 N/m with a standard deviation of 200 N/m. The length of the spring when uncompressed, , is uniformly distributed from 1.45 to 1.55 cm, while the compressed length, , of the spring is uniformly distributed from 0.35 to 0.45 cm. The mass, , of the spring is normally distributed with mean 0.08kg and standard deviation 0.001kg.

We would like to determine the maximum engine speed that would avoid “floating valves”, which is a phenomenon that occurs when the engine speed reaches a certain threshold such that the spring loses contact with the camshaft when the valve closes. This is due to the spring being unable to extend promptly enough to maintain contact with the camshaft.

For the purpose of this tutorial, we will assume that the camshaft rotates at the same speed as the engine. As a result, the time it takes for a spring to uncompress is equal to the time it takes for the engine to rotate through half a cycle. Thus, the spring also performs half a cycle during the valve closing. The time it takes for this half cycle is,

where the frequency of the full cycle is,

Therefore the RPM can be defined as,

The variables in this problem are summarised in the following table.

Random Variables |
Distribution |
---|---|

Mass (m) | N(0.08, 0.001^{2}) kg |

Spring Stiffness (k) | N(20,000,200^{2}) N/m |

Uncompressed Length (L_{0}) |
U(1.45,155) cm |

Compressed Length (L_{compressed}) |
U(0.35,0.45) cm |

# Problem Definition in COSSAN

## Create a Project

To create a new project select the **File** tab on the left hand corner of the window, then select **New**, and **Project**.

Give the project a name ("CompressionSpring") and a description ("Model of Compression Spring"), then select **Finish**.

After, the project name appears in the Workspace on the left hand, all the subfolders will be empty.

## Input

When the project has been created it will appear in the Workspace on the left hand side. The first step is to add and define the model inputs, and in this tutorial all of the input values are random variables.

### Random Variables

To add a random variable as an input:

1. Open the input folder in the workspace area on the left hand side, and right click on ** Random Variables.** Select ** Add Random Variable. **

2. Give the random variable a name ("k") and a brief description ("Stiffness"), then select ** Finish.**

3. In the next window select the distribution type and the distribution parameters. For example the stiffness, is normally distributed with a mean of 20000 and a standard deviation of 200. After the specification of the parameters, the PDF and CDF previews of the random variable are shown. It is necessary to save the data by pressing the save icon or Ctrl+S.

Repeat steps 1-3 for the remaining Random Variables, and . At the end of the procedure, it is possible to see all the defined random variables in the bottom part of the central window of the GUI.

## Matlab Script

To calculate the max RPM a Matlab script needs to be created, in which we will define the equations for the time, frequency, and RPM. To create a Matlab script:

1. Open the Evaluators tab in the Workspace area and select ** Add Matlab script**.

2. Create a new script and provide a name ("SpeedofEngine") and a brief description ("Speed of the Engine in RPM").

An editor will now be displayed which can be used to add the input and output random variables into the script.

4. To add the input Random Variable select the plus button in the input window.

5. Select the required Random Variables.

6. Add a new output by selecting the plus button in the output window ("RPM").

Now that the inputs and output have been defined we can create the Matlab Script. To do this,

7. Select ** Script/Function **at the bottom of the window.

To access the input variables inside the Matlab script, we add **Tinput(n).** prior to the variable name, and to define the output variables we add **Toutput(n).** prior to the variable name. Therefore we define the time, frequency, and RPM as,

1. t = (2.*sqrt(Tinput(n).m / (2*Tinput(n).k)) * (asin(Tinput(n).Lcompressed /1.5 ) - pi/2);

2. f = 1./t;

3. Toutput(n).RPM = f.*60;

where RPM is the only output variable, and t and f are used only inside the script.

## Model

To be able to perform further analysis, such as Sensitivity Analysis, we must first add the physical model that will generate indipendent samples. The physical model allows us to determine the impact of the random variables in the model.

1. To add the physical model, right click on ** Physical Models ** and select ** Add Physical Model. ** (Alternatively, right click ** Models ** and select ** Add Physical Model)**.

2. In the new window, type the name for the model ("PhysicalModelofSpring"), alongside a short description of the model ("Physical Model of Spring"). Click on ** Finish. **

3. Now that we have an empty physical model, we must click on the "** + **" near the ** Evaluator ** box.

4. In the new window, select the necessary function, in our case ** SpeedOfEngine. ** Click ** OK. **

5. The model should then be populated, the input and the output connected with the evaluator are shown in their windows. The screen should look similar to the image below.

When the object is save the red error message on the top dissapear and the model is ready to be analyzed.

In the random variable sets "uncorrelated_rsv" is added automatically by COSSAN-X, it is an uncorrelated random variable set. In our case, there are not correlations between random variables, if not all required random variable sets need to be specified.

# Deterministic Analysis

The purpose of the safety assessment is to demonstrate that the risk related to any facility is at an acceptable level. Particularly, the deterministic analysis aims to demonstrate that the possibility of a "floating valves" is within reasanable limits for safe operation.

1. After defining the inputs, click on ** Run Analysis**.

2. A window will appear with a selection of analyses. Choose ** Design of Experiments** and click on ** Next**.

3. Select ** Deterministic Analysis** and click on ** Next**.

4. Make sure that the Matlab Script is in the window "Analysys Selection" and click ** Finish**.

5. Once you press finish, the engine runs the analysis until it is complete.

### Results

For viewing the results, you need to open **Analysis**, now there will be (1) next to it, you will find all the subfolders with the names of all the possible analysis to perform. The tutorial did only a deterministic analysis, so only **Design of Experiment** is the only analysis with (1) next to it, open it. Open Design of **ExperimentPhysicalModelofSpring_analysys1** and then Results, where you will find **SimulationData_Deterministic_Analysis**, that contains the results of the simulation.

The results will show the expected value of the determinist analysis for engine speed.

# Uncertainty Quantification

Uncertainty Quantification is performed with the aim of determining the likelihood of certain outcomes given that there are some aspects of the system that are not explicitly known. We will perform uncertainty quantification using a Monte Carlo simulation, which utilises the random sampling of the prescribed probability distributions.

1. After saving the data, click the green play button on the top right hand side of the physical model and ** Run Analysis**.

2. Select **Uncertainty Quantification** and click **Next**.

3. Select **Simulation** and click **Next**.

4. The following window appears where various simulation options are possible, select **Monte Carlo** and on the right fill in the number of **samples per batch** required, click **Next**. It is also possible to select the number of batches for splitting the computation, but in this example only one batch is used. At the end, it is possible to define the maximum runtime, choosing zero the limit is not given.

5. In the next mask, it is possible to specify the grid settings, for this example the default settings are good to perform the analysis. Select the **Finish** button and the computation will start.

When the uncertainty quantification analysis is completed, in the console mask will appear a message of successful completion is given.

### Results

As for the deterministic analysis, to view results select ** Analysis ** in the Workspace area and navigate to **SimulationData_batch_1_of_1 **, where all the involved variables involved in the input are shown.

A common method to visualise and analyse the relationships between multiple variables is in Parallel coordinates that allows to show correlation between several varibles. To show a parallel coordinate plot highlight the variables required, and select **Open in Parallel Coordinates View**.

By selecting individual variables inside of this folder the user can visualise their corresponding plots (e.g bar chart, line chart, histogram). Select **RPM** and **Open in Histogram View**.

# Reliability Analysis

In most design problems, uncertainties related to geometries, material properties, manufacturing processes and operating conditions are important factors that should be accurately quantified and included while designing and optimising a realistic system for a required level of reliability and efficiency.

### Initialise Parameter

In order to be able to perform the analysis, the user should define all of the inputs at first. In this example, to perform the reliability analysis it is necessary to add only one parameter to the existing one, the maximum RPM of the engine.

1. Click on ** Input **, Right-Click on ** Parameters ** and ** Add Parameters **.

2. Name the variable ("MaxRPM") and add a brief description of the parameter ("The maximum RPM value"). Then, add how many elements should be in the vector, in this case is a single value so will be 1.

3. Insert the value of the variable: 17000.

### Create Performance Function

The performance function defines the model's domain of definition in two sets: the safe set and the failure set.
To create the performance function, click on **Evaluation**, Right-Click on **Perfomance function** and finally add **Perfomance Function**.

Add the name of the performance function ("SpringFail") and a brief description ("Performance Function for Spring"). The most straightforward way to define a performance function is to fix the demand (the actual RPM of the engine) and the capacity (the maximum RPM of the engine).

Define the ** Demand **, which, in this example is the output of the Matlab script is RPM, and the ** Capacity, ** which is the parameter defined above: MaxRPM. The default value (vg) is used for defining the output of the performance function.

### Create Probabilistic Model

A Probabilistic model could be defined as a statistical analysis tool that is able to estimate, based on data observed from a system, the probability of an event occurring again. It is necessary to define it to perform a reliability analysis.

1. Scroll down ** Models ** and Right-Click on ** Probabilistic Model, ** then ** Add Probabilistic Model. **

2. In "Create a Probabilistic Model", choose a name for the variable ("SpringProbabilistic") and give a brief description of it ("Probabilistic model of spring"). Then, click on ** Finish. **

3. Finally, the user will be able to see a window with a combination of the physical model and the performance function. The input and the output associated with the physical model and the performance function are shown in the right hand of the windows. If not, the user can add them by clicking the plus button and selecting the physical model and the performance function from the lists.

### Perform Reliability Analysis

In order to perform the reliability analysis save the data, click on the ** green play button" ** on the top right of the window.

1. Tick ** Reliability Analysis ** from Analysis Selection and then ** Next **

2. In this tutorial, the goal is to estimate the failure probability associated to the probabilistic model. Choose ** Failure Probability ** and click on ** Next **

3. Then it is possible to select various methods to estimate the failure probability. In this case Monte Carlo is chosen and the number of sample used is 1000. Click on ** Next **

4. In the next window, it is possible to specify the grid settings, and for this example the default settings are good to perform the analysis. Finally, click on ** Finish. **

### Results

When the analysis is complete a message of successful completion is given and the user can check all of the results following this path:

** Reliability Analysis ** -> **Results** -> **Engine Outputs **

In the Results folder, the EngineOutput contains two different items: the MonteCarlo_output and the timer. By selecting the first it is possible to see the probability of failure of the implemented system (pfhat) and the standard deviation of the estimator. Instead, by selecting the timer it is possible to see the computational time of the analysis

# Sensitivity Analysis

Sensitivity analysis is used to identify the most significant factors or variables which affect the results of the model. Local Sensitivity is obtained by varying the input values individually whilst the rest remain fixed to a value, and Global sensitivity is obtained by taking the average of the local sensitivity analysis for the uncertain parameters. It is useful to determine which variable can be changed in order to reduce the probability of failure. Here we will be performing Global sensitivity analysis.

1. Click the green play button on the top right hand side of the physical model editor.

2. Select ** Sensitivity Analysis ** and Click ** Next. **

3. In this window, the user can select the quantity of interest and the output of interest. Select ** Global Sensitivity Measures ** as the quantity of interest and ensure that ** RPM ** is visible in the output window. Click ** Next. **

4. The new window allows the user to select the input variable to be considered in the global sesitivity analysis, the number of bootstrap resamples used to estimate the confidence intervals of the estimated confidence, the number of samples used, and finally the algorithm. Increase the ** Number of Samples ** to 100 and click ** Next **, the default method setting will be used to perform the analysis.

5. This analysis will be performed on a local machine so we do not need to configure the HPC settings. Click ** Finish.**

### Results

Once you have found the location where the results have been written to, clicking on ** SpringProbabilistic_analysis_output ** will display the sensitivity analysis results. Details of the parameters can be visualised using different methods such as: tables, bar histogram, bar chart.