-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectTemplate.py
125 lines (104 loc) · 3.84 KB
/
ProjectTemplate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import os
import imp
import subprocess
INPUT_SERVER_PORT = 10000
plaxis_path = r'c:\Program Files (x86)\Plaxis\Plaxis 2D'
class SimpleProject(object):
"""
Class that provides a way to quickly setup a project for example purposes.
"""
def __init__(self, g_input):
# Import module from plaxis_path. This enables us to store this script
# anywhere we want to.
found_module = imp.find_module('plxscripting', [plaxis_path])
plxscripting = imp.load_module('plxscripting', *found_module)
from plxscripting.easy import new_server
self._new_server = new_server
args = [os.path.join(plaxis_path, "Plaxis2DXInput.exe"),
"--AppServerPort={}".format(INPUT_SERVER_PORT)]
self._input_process = subprocess.Popen(args)
self._s_input, self._g_input = self._new_server(
'localhost', 10000, timeout=10.0)
def gather_results(self):
raise NotImplementedError("Override gather_results in subclass.")
def output_results(self):
raise NotImplementedError("Override output_results in subclass.")
def close_input(self):
self._input_process.kill()
@property
def g_input(self):
return self._g_input
def add_soil_layers(self):
raise NotImplementedError("Override add_soil_layers in subclass.")
def apply_soil_material(self):
SAND_PARAMETERS = [
('MaterialName', 'Sand'),
('Colour', 10676870),
('SoilModel', 3), # Hardening soil
('DrainageType', 'Drained'),
('gammaUnsat', 17),
('gammaSat', 20),
('E50ref', 43000),
('EoedRef', 28000),
('EurRef', 129000),
('powerm', 0.5),
('cref', 1),
('phi', 34.0),
('psi', 4.0),
('nu', 0.2),
('Rinter', 0.7),
('K0NC', 0.5),
('OCR', 1.0),
('POP', 0.0)
]
sand = self._g_input.soilmat(*SAND_PARAMETERS)
for soil_layer in self._g_input.SoilLayers:
self._g_input.setmaterial(soil_layer, sand)
def add_structures(self):
pass # Not adding any plates is fine too.
def apply_plate_materials(self):
DIAPHRAGM_WALL_PARAMETERS = [
('MaterialName', 'Wall'),
('Colour', 16711680),
('Elasticity', 0), # Elastic
('IsIsotropic', True),
('IsEndBearing', True),
('EA', 12000000),
('EI', 120000),
('nu', 0.15),
('d', 0.34641),
('w', 8.3),
('Mp', 1000000000000000.0),
('Np', 10000000000.0),
('Np2', 10000000000.0),
('RayleighAlpha', 0),
('RayleighBeta', 0),
('Gref', 15061311)
]
diaphragm_wall_material = \
self._g_input.platemat(*DIAPHRAGM_WALL_PARAMETERS)
for plate in self._g_input.Plates:
self._g_input.setmaterial(plate, diaphragm_wall_material)
def mesh(self):
self._g_input.gotomesh()
self._g_input.mesh(0.06)
def select_curve_points(self):
pass # Not selecting any curve-points is fine too.
def configure_phases(self):
raise NotImplementedError("Override configure_phases in subclass.")
def make_project(self):
self.add_soil_layers()
self.apply_soil_material()
self.add_structures()
self.apply_plate_material()
self.mesh()
self.select_curve_points()
self.configure_phases()
self._g_input.calculate()
def run(project_class):
# Replace with the path to your PLAXIS installation.
project = project_class(r"c:\Program Files (x86)\Plaxis\PLAXIS 2DX")
project.make_project()
project.gather_results()
project.output_results()
project.close_input()