diff --git a/trussme/member.py b/trussme/member.py index 232b82c..fd984ea 100644 --- a/trussme/member.py +++ b/trussme/member.py @@ -127,10 +127,10 @@ def __init__(self, joint_a: Joint, joint_b: Joint): self.idx = -1 # Shape independent variables - self.shape: Shape = None + self.shape: Shape = Pipe(t=0.002, r=0.02) # Material properties - self.material: Material = None + self.material: Material = MATERIALS[0] # Variables to store information about truss state self._force: float = 0 @@ -138,10 +138,6 @@ def __init__(self, joint_a: Joint, joint_b: Joint): # Variable to store location in truss self.joints = [joint_a, joint_b] - # Calculate properties - self.set_shape(Pipe(t=0.002, r=0.02)) - self.set_material(MATERIALS[0]) - def set_shape(self, new_shape: Shape): self.shape = new_shape @@ -149,6 +145,18 @@ def set_material(self, new_material: Material): # Set material properties self.material = new_material + @property + def yield_strength(self) -> float: + return self.material["yield_strength"] + + @property + def density(self) -> float: + return self.material["density"] + + @property + def elastic_modulus(self) -> float: + return self.material["elastic_modulus"] + @property def moment_of_inertia(self) -> float: return self.shape.moi() @@ -159,7 +167,7 @@ def area(self) -> float: @property def linear_weight(self) -> float: - return self.area * self.material["density"] + return self.area * self.density @property def length(self) -> float: @@ -179,9 +187,9 @@ def force(self, new_force): @property def fos_yielding(self) -> float: - return self.material["yield_strength"] / abs(self.force / self.area) + return self.yield_strength / abs(self.force / self.area) @property def fos_buckling(self) -> float: - return -((numpy.pi**2)*self.material["elastic_modulus"]*self.moment_of_inertia + return -((numpy.pi**2)*self.elastic_modulus*self.moment_of_inertia /(self.length**2))/self.force \ No newline at end of file diff --git a/trussme/truss.py b/trussme/truss.py index 05f8d27..f175da4 100644 --- a/trussme/truss.py +++ b/trussme/truss.py @@ -126,7 +126,7 @@ def calc_fos(self): area = [] connections = [] for m in self.members: - elastic_modulus.append(m.material["elastic_modulus"]) + elastic_modulus.append(m.elastic_modulus) area.append(m.area) connections.append([j.idx for j in m.joints])