Model construction with Python API

Fabiola
Posts: 16
Joined: Tue Jun 07, 2022 7:50 am

Model construction with Python API

Post by Fabiola » Sun Nov 06, 2022 10:04 pm

Dear STKO team,
I'm trying to model a soil domain which is formed by a soil deposit (of 2 layer) on top of a bedrock layer, I attach the draw below.
1. I built the geometry of the 2D model with Python API but i have some problems creating the second layer in my soil deposit. Below i've attached the Python script.
2. I also need to generate some codes (using Python API) to implement the physical properties by specifying various geotechincal parameters to be assigned, how can i do?
For example I have to assign a velocity trend that varies with depth within each layer, is it possible?
Thank you very much!!

Fabiola
Attachments
Stko forum.jpg
Stko forum.jpg (45.52 KiB) Viewed 3980 times
Geometria deposito monostrato_asimmetrico.rar
(2.47 KiB) Downloaded 169 times

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Model construction with Python API

Post by STKO Team » Wed Nov 09, 2022 3:39 pm

Before going ahead with the property assignment, have a look at this modified version of your script:
MakeGeometry.zip
(1.51 KiB) Downloaded 163 times
It's a bit cleaner. It builds the grid lines and then uses them to create the planar faces. In your previous script there was some mistake and some faces were invalid.
Check it and let us know if it works as intended.

Also there is a note at line 75. Please have a look

Fabiola
Posts: 16
Joined: Tue Jun 07, 2022 7:50 am

Re: Model construction with Python API

Post by Fabiola » Fri Nov 18, 2022 9:26 pm

Thank you so much for your help!
I checked the script and it runs very well. Now i'm trying to automate the process of implementing the properties and building the mesh in python. The focus of my work is to develop an automated python code to create the model. I tried to assign the properties directly on stko and then i tried to extract the input files, but i think it's not the right way, Can I have your help for this step?

Thank you again

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Model construction with Python API

Post by STKO Team » Mon Nov 21, 2022 9:33 am

Could you please assign some properties to the model generated by the script, and share it here?
I will show you how to do it in Python.

Fabiola
Posts: 16
Joined: Tue Jun 07, 2022 7:50 am

Re: Model construction with Python API

Post by Fabiola » Mon Nov 21, 2022 9:33 pm

Yes sure, Thank you so much!!!
Attachments
MakeGeometry.rar
(9.44 MiB) Downloaded 206 times

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Model construction with Python API

Post by STKO Team » Tue Nov 22, 2022 3:13 pm

Ok, let's do it one step at a time.
In this script you will see how to:
  • Create a physical property (Soil Material)
  • Assign it to some faces of the geometry
Then you can try to do the same for other properties. For any doubt, ask here.
MakeGeometry.zip
(2.33 KiB) Downloaded 208 times

Fabiola
Posts: 16
Joined: Tue Jun 07, 2022 7:50 am

Re: Model construction with Python API

Post by Fabiola » Fri Dec 09, 2022 6:10 pm

Hi team,
Following your directions I've tried to assign the bedrock the same physical properties but I'm having some difficulty. I attach the model below.
I also have other questions:
1. How can I generate a second layer with variable y (for example also y=0) inside the basin using Python API?
2. How can I create a mesh using Python API?

Thanks for your help.
Attachments
MakeGeometry.rar
(2.37 KiB) Downloaded 175 times

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Model construction with Python API

Post by STKO Team » Wed Dec 14, 2022 4:55 pm

There were some mistakes in the logic for assignment of the bedrock material
MakeGeometry.zip
(2.47 KiB) Downloaded 172 times

Fabiola
Posts: 16
Joined: Tue Jun 07, 2022 7:50 am

Re: Model construction with Python API

Post by Fabiola » Mon Jan 30, 2023 9:21 pm

Hello team,
thanks for your advice!!! I'm here again to ask for your help!
The starting file, this time, is the one updated by my teacher, I attach it below. The next step is to create a routine to define and assign element properties. I hope for your help!
Thank you so much
Attachments
MakeGeometry - MUz - N layers v02.rar
(2.92 KiB) Downloaded 174 times

STKO Team
Posts: 3066
Joined: Tue Oct 29, 2019 8:45 am

Re: Model construction with Python API

Post by STKO Team » Tue Jan 31, 2023 11:54 am

Here it is:
MakeGeometry - MUz - N layers v02.zip
(3.17 KiB) Downloaded 188 times
It follows the same steps as the physical properties.
You just have to figure out what attribute you want to change, and what Type it is (i.e. Real, Integer, QuantityScalar, etc...).
You can do it by looking at the associated python file (in your case the quadUP.py in C:\Program Files\STKO\external_solvers\opensees\element_properties\up_elements)

Post Reply