How to create a parametric tunnel design with SCIA

by VIKTOR

SCIA engineering report
With this open-source Python code you can easily generate parametric tunnel models through an integration with SCIA, without having to open the SCIA interface at all. You can use the functionality either within your own Python code, or through a web application on the VIKTOR platform.
How to create successful application that ensure adoption
Build successful applications

Learn how you (developer, engineer, end-user, domain expert, project manager, etc.) can contribute to the creation of apps that provide real value to your work.

Using the functionality

There are two ways in which you can use this functionality:

  1. With VIKTOR, out-of-the-box, using our free version.

  2. Without VIKTOR, in that case you integrate with your own Python code and create an integration with SCIA yourself.

This is a snippet of the functionality’s code from the VIKTOR GitHub repository.

1@PDFView("PDF View", duration_guess=20) 2def execute_scia_analysis(self, params, **kwargs): 3 """ Perform an analysis using SCIA on a third-party worker""" 4 scia_model = self.create_scia_model(params) 5 input_file, xml_def_file = scia_model.generate_xml_input() 6 scia_model = self.get_scia_input_esa() 7 8 scia_analysis = SciaAnalysis(input_file=input_file, xml_def_file=xml_def_file, scia_model=scia_model, 9 result_type=ResultType.ENGINEERING_REPORT, output_document='Report_1') 10 scia_analysis.execute(timeout=600) 11 engineering_report = scia_analysis.get_engineering_report(as_file=True) 12 13 return PDFResult(file=engineering_report)

This piece of code, located in app/tunnel/controller.py, is used to perform the analysis using SCIA on a third-party worker and generates an engineering report (as shown in the picture) showing the internal stress. The full code can be found in the repository.

In the video you can see the functionality being used in a VIKTOR application.


Parametric tunnel design in 4 steps

As you can see in the video, the process of parametrically designing a tunnel and creating a SCIA model consists of only three easy steps. The step-functionality helps users navigate the application more easily and improves the overall experience:

  1. Select the location of the tunnel by drawing the location on a map, using a GeoPolyline field, determining the number of tunnel segments, and visualizing the tunnel on the map

  2. Define cross-section by adjusting the width, height, number of sections, and thickness of the roof, floor, and wall, and then visualizing one tunnel segment in a 3D visualization.

  3. Create the SCIA model by determining the roof load (kN/m2), soil stiffness (MN/m), visualizing a 2D beam model with the geometry and support.

  4. Generate egineering report automatically from SCIA within the VIKTOR application.

Next, you can simply download the SCIA model (XML). The only requirement to use this application is that you have a SCIA worker running. Information on creating and analyzing SCIA models can be found in the SCIA tutorial in our GitHub repository. More information on workers can be found in the VIKTOR documentation.

Engineering report SCIA tunnel

Engineering report showing the internal stress as generated in step 4

Writing tests and testing the app

Of course, you want to verify that your application works properly. This can be done by testing your application. To get a better understanding of how tests work in VIKTOR, this application includes some simple tests. With these tests, it is important to know that the params need to be mocked. This means that parts of your to-be-tested application are (temporarily) replaced by ‘fake’ objects within the scope of your test, so that you have full control over the in- and output within a certain test function.

In the folder tests/tunnel/test_controller.py, you can see that prior to every test, the tunnel_example_1.json is used to mock the params. In the last test that checks if creating the engineering works, some functions are mocked as well:

1@patch('viktor.external.scia.Model.generate_xml_input', generate_xml_input_mock) 2@patch('app.tunnel.controller.SciaAnalysis.execute', scia_analysis_execute_mock) 3@patch('app.tunnel.controller.SciaAnalysis.get_engineering_report', scia_analysis_get_engineering_report_mock) 4def test_execute_scia_analysis(self): 5 """ Test TunnelController.execute_scia_analysis. It mocks some methods since they are using API calls.""" 6 pdf_result = self.controller.execute_scia_analysis(self.controller, params=self.params) 7 self.assertIsInstance(pdf_result, PDFResult)

This part requires making an API call to the SCIA worker. Because this is not possible during a test, we want to tell the test it needs to skip the API call by using the @patch annotation.

Use our free version to start using this app!

Share

Related Blog Posts

Avoid Piping with Open-Source Web App

Read more

Easily Turn Grasshopper Models into Sharable Web Apps with VIKTOR

Read more

Precipitation tool shows 2023 is another extremely dry year

Read more