Skip to content

Commit

Permalink
🎨 Format Python code with psf/black (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: ccaprani <[email protected]>
  • Loading branch information
github-actions[bot] and ccaprani authored Oct 13, 2023
1 parent e280e64 commit cc0fb4a
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 121 deletions.
6 changes: 3 additions & 3 deletions examples/28m_supert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
m = 1.0
N = 1.0
sec = 1.0
MPa = 1e9 * N / m ** 2
g = 9.81 * m / sec ** 2 # 9.81 m/s2
MPa = 1e9 * N / m**2
g = 9.81 * m / sec**2 # 9.81 m/s2


# variables
E = 34.7 * MPa
G = 20e9 * MPa # Pa
v = 0.3

q = 40e9 * N / m ** 2
q = 40e9 * N / m**2

L = 28 * m
H = 7 * m
Expand Down
6 changes: 3 additions & 3 deletions examples/Example_super_T.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
N = 1
m = 1
mm = milli * m
m2 = m ** 2
m3 = m ** 3
m4 = m ** 4
m2 = m**2
m3 = m**3
m4 = m**4
kN = kilo * N
MPa = N / ((mm) ** 2)
GPa = kilo * MPa
Expand Down
24 changes: 12 additions & 12 deletions src/ospgrillage/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,10 +1277,10 @@ def hermite_shape_function_1d(
.. note::
"""
N1 = 1 - 3 * zeta ** 2 + 2 * zeta ** 3
N2 = (zeta - 2 * zeta ** 2 + zeta ** 3) * a
N3 = 3 * zeta ** 2 - 2 * zeta ** 3
N4 = (-(zeta ** 2) + zeta ** 3) * a
N1 = 1 - 3 * zeta**2 + 2 * zeta**3
N2 = (zeta - 2 * zeta**2 + zeta**3) * a
N3 = 3 * zeta**2 - 2 * zeta**3
N4 = (-(zeta**2) + zeta**3) * a
return [N1, N2, N3, N4]

@staticmethod
Expand All @@ -1293,14 +1293,14 @@ def hermite_shape_function_2d(eta: float, zeta: float):
# | |
# | |
# 1 o - - - o 2
h1 = 0.25 * (2 - 3 * eta + eta ** 3)
h2 = 0.25 * (1 - eta - eta ** 2 + eta ** 3)
h3 = 0.25 * (2 + 3 * eta - eta ** 3)
h4 = 0.25 * (-1 - eta + eta ** 2 + eta ** 3)
z1 = 0.25 * (2 - 3 * zeta + zeta ** 3)
z2 = 0.25 * (1 - zeta - zeta ** 2 + zeta ** 3)
z3 = 0.25 * (2 + 3 * zeta - zeta ** 3)
z4 = 0.25 * (-1 - zeta + zeta ** 2 + zeta ** 3)
h1 = 0.25 * (2 - 3 * eta + eta**3)
h2 = 0.25 * (1 - eta - eta**2 + eta**3)
h3 = 0.25 * (2 + 3 * eta - eta**3)
h4 = 0.25 * (-1 - eta + eta**2 + eta**3)
z1 = 0.25 * (2 - 3 * zeta + zeta**3)
z2 = 0.25 * (1 - zeta - zeta**2 + zeta**3)
z3 = 0.25 * (2 + 3 * zeta - zeta**3)
z4 = 0.25 * (-1 - zeta + zeta**2 + zeta**3)
Nv = [h1 * z1, h3 * z1, h3 * z3, h1 * z3]
Nmz = [h2 * z1, h4 * z1, h4 * z3, h2 * z3]
Nmx = [h1 * z2, h3 * z2, h3 * z4, h1 * z4]
Expand Down
3 changes: 1 addition & 2 deletions src/ospgrillage/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(
c_mass_flag: bool = False,
unit_width: bool = False,
op_section_type: str = "Elastic",
**kwargs
**kwargs,
):
"""
The constructor takes in two types of keyword arguments.
Expand Down Expand Up @@ -244,7 +244,6 @@ def __init__(

self.variable_string_list = []


def get_member_prop_arguments(self, width=1):
"""
Returns the element arguments based on the op_element_type of the GrillageMember.
Expand Down
51 changes: 21 additions & 30 deletions src/ospgrillage/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ def __init__(
global_edge_count: int = 0,
mesh_origin: list = None,
quad_ele: bool = False,
**kwargs
**kwargs,
):

# inputs from OspGrillage required to create mesh
self.long_dim = long_dim
self.trans_dim = trans_dim
Expand Down Expand Up @@ -251,7 +250,7 @@ def __init__(
num_long_beam=self.num_long_beam,
model_plane_y=self.y_elevation,
sweep_path=self.sweep_path,
**kwargs
**kwargs,
)
# intermediate construction lines for
if self.multi_span_dist_list and self.orthogonal:
Expand All @@ -272,7 +271,7 @@ def __init__(
num_long_beam=self.num_long_beam,
model_plane_y=self.y_elevation,
sweep_path=self.sweep_path,
**kwargs
**kwargs,
)

self.multi_span_control_point_list.append(edge_obj)
Expand All @@ -289,7 +288,7 @@ def __init__(
num_long_beam=self.num_long_beam,
model_plane_y=self.y_elevation,
sweep_path=self.sweep_path,
**kwargs
**kwargs,
)
# ------------------------------------------------------------------------------------------
# Sweep nodes
Expand Down Expand Up @@ -570,7 +569,6 @@ def _fixed_sweep_node_meshing(self):
assigned_node_tag = []

def _store_ele_tag_respect_to_mesh_group(self, counter: int, span_group: int):

ele_tag_list = self.span_group_to_ele_tag[span_group]
if counter not in ele_tag_list:
ele_tag_list.append(counter)
Expand Down Expand Up @@ -614,7 +612,6 @@ def _orthogonal_meshing(self):
self.sweep_path_points = []

for i, edge_obj in enumerate(self.multi_span_control_point_list[:-1]):

start_point_x = edge_obj.node_list[0][0]
start_point_z = edge_obj.node_list[0][2]

Expand All @@ -633,7 +630,7 @@ def _orthogonal_meshing(self):
# if curve mesh, rotate the edge sweep nodes
current_sweep_nodes = self._rotate_edge_sweep_nodes(current_sweep_nodes)

for (z_count_int, nodes) in enumerate(current_sweep_nodes):
for z_count_int, nodes in enumerate(current_sweep_nodes):
x_inc = start_point_x
z_inc = start_point_z
node_coordinate = [nodes[0] + x_inc, nodes[1], nodes[2] + z_inc]
Expand Down Expand Up @@ -709,7 +706,7 @@ def _orthogonal_meshing(self):
)

# on each control point, loop through sweeping nodes to create nodes
for (z_count_int, nodes) in enumerate(sweep_nodes):
for z_count_int, nodes in enumerate(sweep_nodes):
x_inc = ref_point_x
z_inc = ref_point_z
node_coordinate = [nodes[0] + x_inc, nodes[1], nodes[2] + z_inc]
Expand Down Expand Up @@ -820,7 +817,7 @@ def _orthogonal_meshing(self):
# #current_sweep_nodes = self._rotate_sweep_nodes(-edge_angle)
# current_sweep_nodes = self._rotate_edge_sweep_nodes(current_sweep_nodes,angle=-edge_angle)

for (z_count_int, nodes) in enumerate(current_sweep_nodes):
for z_count_int, nodes in enumerate(current_sweep_nodes):
x_inc = 0 # end_point_x
z_inc = 0 # end_point_z
node_coordinate = [nodes[0] + x_inc, nodes[1], nodes[2] + z_inc]
Expand Down Expand Up @@ -898,7 +895,7 @@ def _orthogonal_meshing(self):
z_group_recorder = list(
range(z_group, len(current_sweep_nodes))
)
for (z_count_int, nodes) in enumerate(sweep_nodes):
for z_count_int, nodes in enumerate(sweep_nodes):
x_inc = ref_point_x
z_inc = ref_point_z
node_coordinate = [nodes[0] + x_inc, nodes[1], nodes[2] + z_inc]
Expand Down Expand Up @@ -1018,8 +1015,7 @@ def _orthogonal_meshing(self):
# current_sweep_nodes = self._rotate_edge_sweep_nodes(current_sweep_nodes, angle=-current_angle)
# rotating sweep nodes about current nox increment point of uniform region
# if angle less than threshold, assign nodes of edge member as it is
for (z_count_int, nodes) in enumerate(current_sweep_nodes):

for z_count_int, nodes in enumerate(current_sweep_nodes):
node_coordinate = [nodes[0], nodes[1], nodes[2]]
self._assign_node_coordinate(
node_coordinate, z_count_int=z_count_int
Expand Down Expand Up @@ -1541,7 +1537,7 @@ def _get_vector_xz(node_i: list, node_j: list):
x = zi
z = -xi
# normalize vector
length = np.sqrt(x ** 2 + z ** 2)
length = np.sqrt(x**2 + z**2)
x1 = x / length

z1 = z / length
Expand Down Expand Up @@ -1676,9 +1672,8 @@ def __init__(
num_long_beam: int,
model_plane_y: float,
feature: str = "standard",
**kwargs
**kwargs,
):

# set variables
self.edge_ref_point = edge_ref_point
self.width_z = width_z
Expand Down Expand Up @@ -1799,7 +1794,7 @@ def __init__(
num_long_beam: int,
model_plane_y: float,
feature: str = "standard",
**kwargs
**kwargs,
):
# get properties specific to shell mesh
self.beam_width = kwargs.get(
Expand All @@ -1825,7 +1820,7 @@ def __init__(
num_long_beam,
model_plane_y,
feature,
**kwargs
**kwargs,
)

# function specific to shell edge line
Expand Down Expand Up @@ -2028,7 +2023,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
):
"""
Subclass for Mesh with beam. This class creates elements where:
Expand Down Expand Up @@ -2059,7 +2054,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
)
# offset support nodes with rigid distance if provided
if self.rigid_dist_y:
Expand All @@ -2082,7 +2077,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
):
"""
Subclass for Mesh with beam. This class creates elements where:
Expand Down Expand Up @@ -2121,7 +2116,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
)

def _get_geo_transform_tag(self, ele_nodes, offset=None):
Expand Down Expand Up @@ -2177,11 +2172,9 @@ def _get_geo_transform_tag(self, ele_nodes, offset=None):
).tolist()[0][0]
< def_l
):

global_offset_i = [a - b for a, b in zip(node_i, local_offset)]
global_offset_j = [a + b for a, b in zip(node_j, local_offset)]
else: # reciprocal , node i has to minus local offset

global_offset_i = [a + b for a, b in zip(node_i, local_offset)]
global_offset_j = [a - b for a, b in zip(node_j, local_offset)]
global_offset = [global_offset_i, global_offset_j]
Expand Down Expand Up @@ -2211,7 +2204,7 @@ def __init__(
skew_1,
skew_2,
link_type="beam",
**kwargs
**kwargs,
):
"""
Subclass for mesh with offset beam members linked to grillage consisting of shell elements
Expand Down Expand Up @@ -2264,7 +2257,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
)

# meshing procedure to create beam offset element and tie it with rigid links to master nodes of model plane y=0
Expand All @@ -2282,15 +2275,13 @@ def __init__(
# -----------------------------------------------------------------------------------------------------------------
# Functions which are overwritten of that from base class to for specific shell type model
def create_control_points(self, **kwargs):

return ShellEdgeControlLine(**kwargs)

# add groupings of offset beam elements

# ----------------------------------------------------------------------------------------------------------------
# sub procedures specific to shell meshes
def _create_offset_beam_element(self):

# sub procedure function to create beam elements based on offset nodes
self._create_offset_nodes()

Expand Down Expand Up @@ -2481,7 +2472,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
):
# constructor of parent class (BeamMesh) -> base class (Mesh)
super().__init__(
Expand All @@ -2494,7 +2485,7 @@ def __init__(
num_long_beam,
skew_1,
skew_2,
**kwargs
**kwargs,
)
# procedure for creating and assigning spring supports

Expand Down
Loading

0 comments on commit cc0fb4a

Please sign in to comment.