Skip to content

Commit 4485556

Browse files
author
Moreno
committed
Project: add convertLayeredToUniform method to complement convertUniformToLayered()
1 parent 2dcb3b3 commit 4485556

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

famodel/project.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,40 @@ def convertUniformToLayered(self, default_layer=50.0):
13461346
'Su_bot': Su0 + k * default_layer}
13471347

13481348
self.profile_map[name] = [layer] # just layers!
1349+
1350+
def convertLayeredToUniform(self):
1351+
'''
1352+
Converts self.profile_map (layered format) into soilProps (uniform format)
1353+
assuming a single clay layer with linear Su(z) = Su0 + k*z.
1354+
Matches the structure expected by uniform soil models.
1355+
'''
1356+
self.soilProps = {}
1357+
1358+
for name, layers in self.profile_map.items():
1359+
if not layers or len(layers) != 1:
1360+
raise ValueError('convertLayeredToUniform only supports a single-layer profile')
1361+
1362+
layer = layers[0]
1363+
if str(layer.get('soil_type', '')).lower() != 'clay':
1364+
raise ValueError('convertLayeredToUniform only supports clay')
1365+
1366+
top = float(layer['top'])
1367+
bot = float(layer['bottom'])
1368+
Su_top = float(layer['Su_top'])
1369+
Su_bot = float(layer['Su_bot'])
1370+
gamma = float(layer['gamma_top']) # gamma_top == gamma_bot in your format
1371+
1372+
if bot <= top:
1373+
raise ValueError('Invalid layer thickness (bottom <= top)')
1374+
1375+
thickness = bot - top
1376+
k = (Su_bot - Su_top)/thickness
1377+
Su0 = Su_top - k*top
1378+
1379+
self.soilProps[name] = {
1380+
'gamma': [gamma],
1381+
'Su0': [Su0],
1382+
'k': [k]}
13491383

13501384
# # ----- Anchor
13511385
def updateAnchor(self,anch='all',update_loc=True):

0 commit comments

Comments
 (0)