<jupyter_start><jupyter_text>A 3D Euler-Bernoulli Beam is extended to a torsion-bending coupled beam.coordinate system: x -> longitudinal axis, y -> perpendicularThe coupling achieved by introducing parametric coupling terms into the stiffness matrix. To get a proper coupling also adjusting severeal Material parameters.The procedure towards a coupled beam includes 3 Steps:   1. Material parameters are optimized such that target Eigenfrequencies are reached.    2. The coupling paramters are optimized such the the eigen deformations are reached.   3. The Material parameters are readjusted such that the Eigenfreuqencies are reached againFor the coupling optimization a target is required. Two different targets are implemented:   - target based on a reference Eigenvalue analysis of a coupled model including the Eigenfrequencies and eigen deformations    - target based on the assumption that in a coupled case the bedning deformation is reduced by some factor whereas the torsional     deformation increases in the same mode Model geometric, material and element parameters are defined here.For the CAARC standard tall building 'A' and 'B' model parameters are availble.Set model = 'custom' if not using one of these parameters<jupyter_code>model = 'B' #'A', 'custom'

if model == 'custom':
    parameters = {  
                'dimension': '3D',
                'n_elements': 10,
                'nodes_per_elem': 2,
                'lx_total_beam': 180,
                'material_density': 100, 
                'E_Modul': 286100000.0,
                'nu': 0.1, 
                'damping_coeff': 0.025,
                'cross_section_area': 30*45,
                'B':45,
                'D':30,
                'Iy': 227812.5,
                'Iz': 101250.0,
                'I_param':10000.0, 
                'It': 50000.0,
                'modes_to_consider': 15,
                'static_load_magnitude': -20.0,
                'dynamic_load_file': os_join(*["inputs","forces","dynamic_force_11_nodes.npy"]),
                'inital_params_yg': [1.0,1.0,1.0],
                'params_k_ya': [0,0],
                'params_m_ya': [0.0,0.0,0.0],
                'eigen_freqs_tar':[0.2591, 0.3249, 1.3555],
             }
else:
    parameters = model_parameters.parameters[model]

analysis_parameters = model_parameters.dynamic_analysis_parameters

intermediate_results = {'eigenfrequencies':[],
                         'eigenmodes':[],
                         'dynamic_analysis':[],
                         'static_analysis':[]}<jupyter_output><empty_output><jupyter_text>1. StepInitially a beam is created and its material properties are tuned such that the target frequencies are achived.<jupyter_code># CREATE AN INITAL BEAM
# with initial frequency adjustments
beam = BeamModel(parameters, coupled=False, optimize_frequencies_init=True, use_translate_matrix=False)

# collect initial results
intermediate_results['eigenfrequencies'].append(beam.eigenfrequencies)
intermediate_results['eigenmodes'].append(beam.eigenmodes)

dynamic_analysis_init = DynamicAnalysis(beam, parameters = analysis_parameters)
dynamic_analysis_init.solve()
intermediate_results['dynamic_analysis'].append(dynamic_analysis_init)

beam.static_analysis_solve(apply_mean_dynamic=True, directions='all')
intermediate_results['static_analysis'].append(beam.static_deformation)<jupyter_output>C:\Users\Johannes\anaconda3\lib\site-packages\scipy\optimize\_minimize.py:777: RuntimeWarning: Method 'bounded' does not support relative tolerance in x; defaulting to absolute tolerance.
  warn("Method 'bounded' does not support relative tolerance in x; "
c:\Users\Johannes\Documents\TUM\5.MasterThesis\CoupledBeams\3DBeam\source\model.py:203: RuntimeWarning: invalid value encountered in sqrt
  self.eig_values = np.sqrt(np.real(self.eigen_values_raw))
c:\Users\Johannes\Documents\TUM\5.MasterThesis\CoupledBeams\3DBeam\source\model.py:206: RuntimeWarning: divide by zero encountered in true_divide
  self.eig_periods = 1 / self.eigenfrequencies
c:\Users\Johannes\Documents\TUM\5.MasterThesis\CoupledBeams\3DBeam\source\model.py:341: RuntimeWarning: divide by zero encountered in double_scalars
  [[1 / self.eig_values[self.eig_freqs_sorted_indices[mode_i]],<jupyter_text>2. StepThe coupling terms are intorduced and optimized such that the target eigenform is reached.In the optimization paramteres some settings can be made that influence the optimization. For CAARC 'A' and 'B' sensible settings are available. Explanation for target_to_use:- 'realistic': taking values from full 3D FE simulation of exccentirc building (ARiedls work for CAARC 'B')- 'semi_realistic': 'factor_y' times the initial lateral displacement & ratio_a_y_tar at the tip; alpha twist displacement is amplified -> original shape is taken- 'custom': 'factor_y' times the initial lateral displacement & ratio_a_y_tar at the tip; a displacement is assumed linear<jupyter_code># # AVAILABLE OPTIMIZATION OPTIONS AND INPUT PARAMETER SETTINGS
opt_methods = ['Nelder-Mead', 'SLSQP', 'Powell', 'BFGS', 'L-BFGS-B','TNC', 'CG']

optimization_variables = ['kya','kga','both']

weights = [[0.33,0.33,.33],[0.5,0.5,0.],[.4,.4,.2],[.45,.45,.1],[.8,.1,.1],[.1,.8,.1],[.2,.4,.4],[0.1,0.1,0.8]]

if model == 'custom':
    optimization_parameters = {
                            'eigen_freqs_tar':[0.2591, 0.3249, 1.3555],
                            'coupling_target':'semi_realistic', # custom, semi_realistic, realistic
                            'ratio_a_y_tar': 0.00372,
                            'factor_y':0.9,
                            'readjust':{'sway_z':True,'sway_y':False,'torsion':False},
                            'consider_mode':0,
                            'var_to_optimize' :optimization_variables[2],
                            'include_mass':False,
                            'method': opt_methods[1],
                            'init_guess':[0.,10.,0],#3 elems: 0,10,0 # k_ya, k_ga, m_cross
                            'bounds':((0.01, 100),(0.01, 100),(.0000001, 100)), #NOTE m seems to be corrected down always 
                            'weights':weights[1],
                            'save_optimized_parameters':False
                            }
else:
    optimization_parameters = model_parameters.optimization_parameters[model]<jupyter_output><empty_output><jupyter_text>The coupling optimization<jupyter_code>coupling_opt = Optimizations(beam, optimization_parameters)

var_to_optimize = optimization_parameters['var_to_optimize']
if var_to_optimize != 'both':
   # optimize onyl one stiffness variable
   coupling_opt.eigen_ya_stiffness_opt(which = var_to_optimize)   
else:
   # optimizing both stiffness variabels
   coupling_opt.eigen_vectorial_ya_opt(target_to_use=optimization_parameters['coupling_target'])

intermediate_results['coupling_optimization'] = coupling_opt

coupled_beam = beam.update_optimized_parameters(coupling_opt.optimized_design_params)
intermediate_results['eigenfrequencies'].append(coupled_beam.eigenfrequencies)
intermediate_results['eigenmodes'].append(coupled_beam.eigenmodes)<jupyter_output>not optimizing the mass entries, thus...
  ...dropping the 3rd bound given
  ...dropping the 3rd initial guess given

Optimization terminated successfully    (Exit mode 0)
            Current function value: 0.02569816618806063
            Iterations: 7
            Function evaluations: 21
            Gradient evaluations: 7

optimized parameters:
  k_ya: 0.01 absolute: 9811385.0
  k_ga: 6.27241 absolute: -664642942671.0

updating:
     Iz from 101250 to 63712.0 increasing by: -37.07 %
     Iy from 227812 to 83680.0 increasing by: -63.27 %
     It from 50000 to 127652.0 increasing by: 155.3 %
     Ip from 2005541.0 to 2005541.0 increasing by: -0.0 %
     params_k_ya from [0, 0] to [0.01       6.27240804] (k_ya, kga)

updated optimized parameters<jupyter_text>3. StepReadjusting eigenfrequencies with the material parameters.<jupyter_code>opt_params_readjust = {'init_guess':[10,10], 'bounds':(0.001,100),'weights':None,'consider_mode':None,'method':None}
print ('\nOptimization of frequency after coupling...')

if optimization_parameters['readjust']['sway_z']: 
   freq_opt = Optimizations(model=coupled_beam, optimization_parameters=opt_params_readjust)
   print ('   ...readjusting stiffness for sway_z')
   freq_opt.adjust_sway_z_stiffness_for_target_eigenfreq(parameters['eigen_freqs_tar'][0], 
                                                         target_mode = 0,
                                                         print_to_console=True)
if optimization_parameters['readjust']['sway_y']: 
   freq_opt_y = Optimizations(model=coupled_beam, optimization_parameters=opt_params_readjust)
   print ('   ...readjusting stiffness for sway_y')
   freq_opt_y.adjust_sway_y_stiffness_for_target_eigenfreq(parameters['eigen_freqs_tar'][1], 
                                                         target_mode = 1,
                                                         print_to_console=True)

if optimization_parameters['readjust']['torsion']:
   freq_opt_torsion = Optimizations(model=coupled_beam, optimization_parameters=opt_params_readjust)                                                     
   print ('   ...readjusting stiffness for sway_torsion')
   freq_opt.adjust_torsional_stiffness_for_target_eigenfreq(parameters['eigen_freqs_tar'][2], 
                                                            target_mode = 2,
                                                            print_to_console=True)

intermediate_results['eigenfrequencies'].append(coupled_beam.eigenfrequencies)
intermediate_results['eigenmodes'].append(coupled_beam.eigenmodes)

dynamic_analysis_coupled = DynamicAnalysis(coupled_beam, parameters = analysis_parameters)
dynamic_analysis_coupled.solve()
intermediate_results['dynamic_analysis'].append(dynamic_analysis_coupled)

coupled_beam.static_analysis_solve(apply_mean_dynamic=True, directions='all')
intermediate_results['static_analysis'].append(coupled_beam.static_deformation)<jupyter_output>Optimization of frequency after coupling...
   ...readjusting stiffness for sway_z
  INITIAL iz: 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382, 63712.5284086382

  OPTIMIZED iz:  83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035, 83679.5617819035

  FACTOR:  1.313392575557528
  Final Func: 0.024664720672798207<jupyter_text>Postprocess the collected resultsWith the postprocess_parameters set which quantities etc. to show<jupyter_code>postprocess_parameters = {
                  'show_plots':True,
                  'savefig':False,
                  'optimization_procedure':{'intermediate_eigenmodes':True, 'objective_function':False},
                  'eigenmodes':{'do':False, 'n_modes':3, 'add_max_val':False, 'max_norm':False, 'rad_scale':True, 'caarc_A_only':False}, # with ajdusted frequencies
                  'static_analysis':{'do':False, 'load_directions':['y','a']},
                  'dynamic_analysis':{'do':True, 'time_hist':True, 'comp_stats':True,'comp_energy':True, 'normed':False,
                                                 'response':'total','response_type':'acceleration', 'node_id':10,'save_object':False, #response: use 'total' for acceleration total
                                                 'stats':['mean', 'std','max_est'],'unit':'MN', 'save_suffix':'_couple_uncouple_quer_1'},
                 }
                 
plt.rcParams['text.latex.preamble']=[r"\usepackage{lmodern}"]

width = utils.cm2inch(14)
height = utils.cm2inch(10)

latex = False
savefig = False

plot_params = plot_settings.get_params(width =width, height=height, usetex=latex, minor_ticks=False)

plt.rcParams.update(plot_params)
# # POSTPROCESSING OBJECT
postprocess = Postprocess(postprocess_parameters, intermediate_results, beam, caarc_model=model)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10230094355239198, 'fraction_numerical': 0.05934447939082933, 'mean_word_length': 3.3292726621282696, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '264418', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 4153, 'n_tokens_neox': 3554, 'n_words': 763, 'path': '3DBeam/run_model.ipynb', 'repo_name': 'JoZimmer/Beam-Models', 'size': '12082'}