11from dataclasses import dataclass
22from typing import Optional
33from load_distribution import Singularity , singularities_to_polygon
4+ from .geom_ops import round_to_close_integer as rtci
45
56@dataclass
67class LinearReaction :
@@ -45,7 +46,7 @@ def extract_reaction(self, xa: float, xb: float) -> "LinearReaction":
4546 xj = xb
4647 yj = y0 + (xj - self .x0 ) * m
4748
48- return LinearReaction (yi , yj , xi , xj )
49+ return LinearReaction (rtci ( yi ), rtci ( yj ), rtci ( xi ), rtci ( xj ) )
4950
5051
5152@dataclass
@@ -73,18 +74,19 @@ def from_projected_loads(
7374 x0 = location_start_key
7475 x1 = location_end_key
7576 linear_reaction_components = {}
76- for load_dir , dir_loads in projected_loads .items ():
77+ for load_dir , load_cases in projected_loads .items ():
7778 linear_reaction_components .setdefault (load_dir , {})
78- for load_case , distributed_loads in dir_loads .items ():
79+ for load_case , applied_loads in load_cases .items ():
7980 linear_reaction_components [load_dir ].setdefault (load_case , [])
80- for distributed_load in distributed_loads :
81+ for applied_load in applied_loads :
8182 linear_reaction = LinearReaction (
82- distributed_load [w0 ],
83- distributed_load [ w1 ] ,
84- distributed_load [x0 ],
85- distributed_load [ x1 ] ,
83+ applied_load [w0 ],
84+ applied_load . get ( w1 ) ,
85+ applied_load [x0 ],
86+ applied_load . get ( x1 ) ,
8687 )
87- linear_reaction_components [load_dir ][load_case ].append (linear_reaction )
88+
89+ linear_reaction_components [load_dir ][load_case ].append (linear_reaction )
8890 return cls (linear_reaction_components , w0 , w1 , x0 , x1 )
8991
9092
@@ -147,16 +149,28 @@ def consolidate_reactions(
147149 x1 = self .location_end_key
148150 reaction_components = {}
149151 flattened_reaction_components = []
150- for load_dir , dir_loads in self .linear_reactions .items ():
152+ for load_dir , load_cases in self .linear_reactions .items ():
151153 reaction_components .setdefault (load_dir , {})
152- for load_case , linear_reactions in dir_loads .items ():
154+ for load_case , linear_reactions in load_cases .items ():
153155 reaction_components [load_dir ].setdefault (load_case , [])
154156 singularity_functions = []
155157 for lr in linear_reactions :
156- m = (lr .w1 - lr .w0 ) / (lr .x1 - lr .x0 )
157- y0 = lr .w0
158- singularity_function = Singularity (x0 = lr .x0 , y0 = y0 , x1 = lr .x1 , m = m , precision = 3 )
159- singularity_functions .append (singularity_function )
158+ if lr .w1 is None and lr .x1 is None :
159+ point_load = {w0 : lr .w0 , x0 : lr .x0 , dir_key : load_dir , case_key : load_case }
160+ print (f"{ point_load = } " )
161+ flattened_reaction_components .append (
162+ point_load
163+ )
164+ reaction_components [load_dir ][load_case ].append (
165+ point_load
166+ )
167+ else :
168+ m = (lr .w1 - lr .w0 ) / (lr .x1 - lr .x0 )
169+ y0 = lr .w0
170+ singularity_function = Singularity (x0 = lr .x0 , y0 = y0 , x1 = lr .x1 , m = m , precision = 6 )
171+ print (singularity_function )
172+ singularity_functions .append (singularity_function )
173+ if not singularity_functions : continue
160174 linear_reactions = singularity_xy_to_distributed_loads (
161175 singularities_to_polygon (
162176 singularity_functions , xy = True
@@ -173,7 +187,7 @@ def consolidate_reactions(
173187 flattened_reaction_components .append (linear_reactions )
174188
175189 # Get ride of the extrandious dir and case keys for unflattened results
176- reaction_components [load_dir ][load_case ] = linear_reactions
190+ reaction_components [load_dir ][load_case ] + = linear_reactions
177191 if flatten :
178192 return flattened_reaction_components
179193 return reaction_components
@@ -219,16 +233,16 @@ def singularity_xy_to_distributed_loads(
219233 w1 = magnitude_end_key
220234 x0 = location_start_key
221235 x1 = location_end_key
222- filtered = filter_repeated_y_values (xy_vals )
223236 dist_loads = []
224237 prev_x = None
225- for idx , (x , y ) in enumerate (filtered ):
238+ for idx , (x , y ) in enumerate (zip (* xy_vals )):
239+ print (f"{ (x , y )= } " )
226240 if idx == 0 : continue
227241 if prev_x is None :
228242 prev_x = x
229243 prev_y = y
230244 elif x - prev_x > 1e-3 :
231- dist_load = {w0 : prev_y , w1 : y , x0 : prev_x , x1 : x , case_key : case , dir_key : dir }
245+ dist_load = {w0 : float ( rtci ( prev_y )) , w1 : float ( rtci ( y )) , x0 : float ( rtci ( prev_x )) , x1 : float ( rtci ( x )) , case_key : case , dir_key : dir }
232246 dist_loads .append (dist_load )
233247 prev_x = x
234248 prev_y = y
0 commit comments