Skip to content

Commit 30ca6d1

Browse files
author
Moreno
committed
Updated project; replaced anchor_soil example with layered/uniform variants
1 parent b808038 commit 30ca6d1

File tree

4 files changed

+100
-2
lines changed

4 files changed

+100
-2
lines changed

examples/05_Anchors/anchor_soil.py renamed to examples/05_Anchors/anchor_soil_layered.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# Step 3: Assign local soil profile from project (nearest neighbor lookup)
2424
soil_id, soil_profile = proj.getSoilAtLocation(anchor.r[0], anchor.r[1])
2525
anchor.soilProps = {soil_id: soil_profile}
26-
anchor.setSoilProfile([{ 'name': soil_id, 'layers': soil_profile }]) # ensures `anchor.soil_profile` is set
26+
anchor.setSoilProfile([{'name': soil_id, 'layers': soil_profile}]) # ensures `anchor.soil_profile` is set
2727

2828
# Step 4: Assign loads and line
2929
anchor.loads = {'Hm': 2e6, 'Vm': 1.5e6}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
import sys
3+
sys.path.append(r'C:\Code\FAModel_anchors\famodel')
4+
5+
from project import Project
6+
from anchors.anchor import Anchor
7+
8+
# Step 1: Initialize and load soil
9+
proj = Project()
10+
proj.loadSoil(
11+
filename='inputs/GulfOfMaine_soil_layered_100x100.txt',
12+
soil_mode='uniform') # 'uniform' soil does not need from the profile_source yaml file
13+
14+
for label, props in proj.soilProps.items():
15+
print(f"{label}: {props}")
16+
17+
# Convert to profile_map format so anchor capacity models can use it
18+
proj.convertUniformToLayered(default_layer=50.0)
19+
20+
for label, props in proj.profile_map.items():
21+
print(f"{label}: {props}")
22+
23+
# Step 2: Create and register an anchor at a known position in the grid
24+
anchor = Anchor(
25+
dd = {'type': 'suction', 'design': {'D': 3.5, 'L': 12.0, 'zlug': 9.67}},
26+
r = [54.0, -4450.0, 0.0])
27+
28+
# Step 3: Assign local soil profile from project (nearest neighbor lookup)
29+
soil_id, _ = proj.getSoilAtLocation(anchor.r[0], anchor.r[1])
30+
soil_profile = proj.profile_map[soil_id] # get compatible layered format
31+
anchor.soilProps = {soil_id: soil_profile}
32+
anchor.setSoilProfile([{'name': soil_id, 'layers': soil_profile}]) # ensures `anchor.soil_profile` is set
33+
34+
# Step 4: Assign loads and line
35+
anchor.loads = {'Hm': 1e6, 'Vm': 5e4}
36+
anchor.line_type = 'chain'
37+
anchor.d = 0.16
38+
anchor.w = 5000.0
39+
40+
# Step 5: Run capacity check and optimization
41+
anchor.getLugForces(
42+
Hm=anchor.loads['Hm'], Vm=anchor.loads['Vm'],
43+
zlug = anchor.dd['design']['zlug'],
44+
d=anchor.d, w=anchor.w,
45+
plot=True)
46+
47+
anchor.getCapacityAnchor(
48+
Hm=anchor.loads['Hm'], Vm=anchor.loads['Vm'],
49+
zlug = anchor.dd['design']['zlug'],
50+
line_type=anchor.line_type, d=anchor.d, w=anchor.w,
51+
mass_update=True,
52+
plot=True)
53+
anchor.getCostAnchor()
54+
print(f'Material cost: {anchor.cost["Material cost"]:.2f} USD [2024]')
55+
56+
results = anchor.getSizeAnchor(
57+
geom = [anchor.dd['design']['L'], anchor.dd['design']['D']],
58+
geomKeys = ['L', 'D'],
59+
geomBounds = [(8.0, 15.0), (2.0, 4.0)],
60+
loads = None,
61+
lambdap_con = [3, 6],
62+
zlug_fix = False,
63+
safety_factor = {'SF_combined': 1},
64+
plot = True)
65+
66+
# Step 6: Report
67+
print('\nFinal Optimized Anchor:')
68+
print('Design:', anchor.dd['design'])
69+
print('Capacity Results:', anchor.anchorCapacity)
70+
anchor.getCostAnchor()
71+
print(f'Material cost: {anchor.cost["Material cost"]:.2f} USD [2024]')
72+
73+

famodel/anchors/anchor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def interpolateSoilProfile(self, profile_map):
205205
self.soilProps = dict(soilProps)
206206

207207
print(f"[Anchor] Interpolated soil profile: {self.profile_name} with soil types {self.soil_type_list}")
208-
208+
209209
def makeMoorPyAnchor(self, ms):
210210
'''
211211
Create a MoorPy anchor object in a MoorPy system.

famodel/project.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,31 @@ def getSoilAtLocation(self, x, y):
11661166
print(f"[DEBUG] Available soilProps keys: {list(self.soilProps.keys())}")
11671167
else:
11681168
raise ValueError("No soil grid defined")
1169+
1170+
def convertUniformToLayered(self, default_layer=50.0):
1171+
'''
1172+
Converts self.soilProps (uniform format) into profile_map (layered format)
1173+
using a default thickness and assuming uniform clay profile.
1174+
Matches the structure of layered CPT-based soil profiles.
1175+
'''
1176+
self.profile_map = {}
1177+
1178+
for name, props in self.soilProps.items():
1179+
name = str(name)
1180+
gamma = float(props['gamma'][0])
1181+
Su0 = float(props['Su0'][0])
1182+
k = float(props['k'][0])
1183+
1184+
layer = {
1185+
'soil_type': 'clay',
1186+
'top': 0.0,
1187+
'bottom': default_layer,
1188+
'gamma_top': gamma,
1189+
'gamma_bot': gamma,
1190+
'Su_top': Su0,
1191+
'Su_bot': Su0 + k * default_layer}
1192+
1193+
self.profile_map[name] = [layer] # just layers!
11691194

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

0 commit comments

Comments
 (0)