@@ -634,20 +634,18 @@ def getCapacityAnchor(self, Hm, Vm, zlug, line_type=None, d=None, w=None, mass_u
634634 self .anchorCapacity ['Rotational displacement' ] = results ['Rotational displacement' ]
635635
636636 # Weight calculated via dimensions
637- if mass_update == False :
637+ if not mass_update :
638638 if 'Weight pile' in results :
639639 self .anchorCapacity ['Weight pile' ] = results ['Weight pile' ]
640640 if 'Weight plate' in results :
641641 self .anchorCapacity ['Weight plate' ] = results ['Weight plate' ]
642642 else :
643643 if 'Weight pile' in results :
644- if self .mass is None :
645- self .mass = results ['Weight pile' ]/ self .g
646- self .anchorCapacity ['Weight pile' ] = self .mass * self .g
644+ self .mass = results ['Weight pile' ]/ self .g
645+ self .anchorCapacity ['Weight pile' ] = results ['Weight pile' ]
647646 if 'Weight plate' in results :
648- if self .mass is None :
649- self .mass = results ['Weight plate' ]/ self .g
650- self .anchorCapacity ['Weight plate' ] = self .mass * self .g
647+ self .mass = results ['Weight plate' ]/ self .g
648+ self .anchorCapacity ['Weight plate' ] = results ['Weight plate' ]
651649
652650 # print(f"[DEBUG] Stored Lateral displacement in anchorCapacity: {self.anchorCapacity['Lateral displacement']:.6f}")
653651
@@ -1312,9 +1310,17 @@ def getSafetyFactor(self):
13121310
13131311 return {'SF_combined' : SF }
13141312
1315- def getCostAnchor (self , ms = None ):
1313+ def getCostAnchor (self , ms = None , mass_update = True ):
13161314 '''
13171315 Assign material cost using a Point object and getCost_and_MBL().
1316+
1317+ Parameters
1318+ ----------
1319+ ms : MoorPy System, optional
1320+ The mooring system to which the anchor point belongs. If None, a new one is created.
1321+ mass_update : bool, optional
1322+ If True, update mpAnchor mass from self.mass.
1323+ If False, preserve existing mpAnchor.m if already set.
13181324 '''
13191325
13201326 # Create or use existing MoorPy system
@@ -1324,12 +1330,12 @@ def getCostAnchor(self, ms=None):
13241330 # Create MoorPy Point using makeMoorPyAnchor
13251331 self .makeMoorPyAnchor (ms )
13261332
1327- # Check if mass is assigned
1328- if self .mass is None :
1333+ # Assign self. mass if missing
1334+ if self .mass is None or mass_update :
13291335 if 'Weight pile' in self .anchorCapacity :
1330- self .mass = self .anchorCapacity ['Weight pile' ] / self .g
1336+ self .mass = self .anchorCapacity ['Weight pile' ]/ self .g
13311337 elif 'Weight plate' in self .anchorCapacity :
1332- self .mass = self .anchorCapacity ['Weight plate' ] / self .g
1338+ self .mass = self .anchorCapacity ['Weight plate' ]/ self .g
13331339 else :
13341340 raise KeyError ("Missing 'Weight pile' or 'Weight plate' in anchorCapacity. \
13351341 Run getCapacityAnchor() before getCostAnchor(), or define self.mass explicitly." )
0 commit comments