From 2eec15f79e659fa13283dad7917b0469f822c03b Mon Sep 17 00:00:00 2001 From: Alvaro Cea Date: Thu, 21 Nov 2024 14:42:52 +0000 Subject: [PATCH] BUG random loading working --- examples/BUG/modelgeneration.org | 181 +++++++++++++++++++++++-------- 1 file changed, 136 insertions(+), 45 deletions(-) diff --git a/examples/BUG/modelgeneration.org b/examples/BUG/modelgeneration.org index 452a6b5..6baded3 100644 --- a/examples/BUG/modelgeneration.org +++ b/examples/BUG/modelgeneration.org @@ -23,18 +23,20 @@ pathlib.Path('./NASTRAN/simulations_out').mkdir(parents=True, exist_ok=True) pathlib.Path('./NASTRAN/Gusts').mkdir(parents=True, exist_ok=True) pathlib.Path('./figs').mkdir(parents=True, exist_ok=True) - #+end_src +#+end_src -P1_modalsolution.py -> -P2_runmodal.sh -> Run Nastran modal solution -P3_dlm.py -> -P4_rundihedral.sh -> -P5_getdihedral.py -> -P6_outputgafs.py -> -P7_rungafs.sh -> -P8_rungafSteady.sh -> -P9_getgafSteady.py -> -P10_rogerRFA.py -> +#+begin_src shell :tangle ./ + python P1_modalsolution.py + source P2_runmodal.sh # Run Nastran modal solution + python P3_dlm.py + source P4_rundihedral.sh + python P5_getdihedral.py + python P6_outputgafs.py + source P7_rungafs.sh + source P8_rungafSteady.sh + python P9_getgafSteady.py + python P10_rogerRFA.py +#+end_src * Modal Solution @@ -2127,11 +2129,12 @@ Running Nastran using the tailored functions in run_nastra.sh which moves output *** Discrete loads Forces and moments at node 35 and 61 + #+begin_src python :tangle settings_DiscreteLoadsMC.py :session *pyshard3* <> <> inp.driver.sol_path = pathlib.Path( - "./results1DiscreteMC") + "./results/DiscreteLoads1") inp.simulation.typeof = "single" inp.system.name = "s1" @@ -2148,48 +2151,89 @@ Forces and moments at node 35 and 61 inp.system.t = [1, 2, 3] # rwing: 14-35 # lwing: 40-61 - inputforces = dict(follower_points=[[[35, 0], [61, 0]], - [[35, 1], [61, 1]], - [[35, 2], [61, 2]], - [[35, 3], [61, 3]], - [[35, 4], [61, 4]], - [[35, 5], [61, 5]], + # [[[node_i, component_j]..(total_forces per run)],...(parallel forces)[[node_i, component_j]..]] + inputforces = dict(follower_points=[[[35, 0], [61, 0], [35, 1], [61, 1]], + [[35, 1], [61, 1], [35, 0], [61, 0]], + [[35, 2], [61, 2], [35, 0], [61, 0]], + [[35, 3], [61, 3], [35, 0], [61, 0]], + [[35, 4], [61, 4], [35, 0], [61, 0]], + [[35, 5], [61, 5], [35, 0], [61, 0]], [[35, 2], [61, 2], [35, 4], [61, 4]], [[35, 2], [61, 2], [35, 4], [61, 4]], - ], # [[[node_i, component_j]..(total_forces per run)],...(parallel forces)[[node_i, component_j]..]] - follower_interpolation= [[[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]], - [[0.,2e5,3.e5], - [0.,2e5,3.e5]] - ] # [[[0,...interpolation points]..(total_forces per run)],...(parallel forces)[[0,...]..]] + ], + # [[[0,...interpolation points]..(total_forces per run)],...(parallel forces)[[0,...]..]] + follower_interpolation= [[[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 0., 0., 0.], + [0., 0., 0., 0.]], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 0., 0., 0.], + [0., 0., 0., 0.]], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 0., 0., 0.], + [0., 0., 0., 0.]], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 0., 0., 0.], + [0., 0., 0., 0.]], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 0., 0., 0.], + [0., 0., 0., 0.]], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 0., 0., 0.], + [0., 0., 0., 0.]], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3] + ], + [[0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3], + [0., 2e3, 3.e3, 5e3]] + ] ) inp.system.shard = dict(input_type="pointforces", - inputs=inputforces) + inputs=inputforces) sol = feniax.feniax_shardmain.main(input_dict=inp, device_count=8) +#+end_src + +**** Plot results +#+NAME: 3Dstatic +#+begin_src python :session *pyshard4* + import feniax.plotools.reconstruction as reconstruction + import feniax.preprocessor.configuration as configuration + config = configuration.Config(inp) + rintrinsic, uintrinsic = reconstruction.rbf_based( + nastran_bdf="./NASTRAN/BUG103.bdf", + X=config.fem.X, + time=range(len(inp.system.t)), + ra=sol.staticsystem_sys1.ra[0], + Rab=sol.staticsystem_sys1.Cab[0], + R0ab=sol.staticsystem_sys1.modes.C0ab, + vtkpath=inp.driver.sol_path / "paraview/bug", + plot_timeinterval=1, + plot_ref=True, + tolerance=1e-3, + size_cards=8, + rbe3s_full=False, + ra_movie=None) #+end_src *** Discrete loads Montecarlo -#+begin_src python :tangle settings_DiscreteLoadsMC.py :session *pyshard3* +#+begin_src python :tangle settings_DiscreteLoadsMC.py :session *pyshard4* <> <> inp.driver.sol_path = pathlib.Path( - "./results1DiscreteMC") + "./results/DiscreteMC1") inp.simulation.typeof = "single" inp.system.name = "s1" @@ -2207,27 +2251,74 @@ Forces and moments at node 35 and 61 # rwing: 14-35 # lwing: 40-61 points = [] - _interpolation = [0.,1e4, 2e4, 3.e4] + interpolation = [] + _interpolation = [0., 1.e4, 1.2e4, 1.5e4] # 1.5e4, 2e4] #[0., 0., 0., 0.] + _interpolation_torsion = [0., 1e4, 2e4, 3e4] for ri,li in zip(range(14, 36),range(40,62)): points.append([ri, 2]) + points.append([ri, 4]) points.append([li, 2]) - interpolation = np.array([_interpolation for pi in points]) # + points.append([li, 4]) + for i, _ in enumerate(range(len(points))): + + if i % 2 == 0: + interpolation.append(_interpolation) + else: + interpolation.append(_interpolation_torsion) + + interpolation = np.array(interpolation) # num_pointforces x num_interpolation paths = 8*10 - mu = 0. - sigma = 1 + sigma0 = 0.15 + mu = _interpolation[-1] + sigma = (1 + sigma0) * _interpolation[-1] rand = np.random.normal(mu, sigma, paths) - follower_interpolation = [interpolation * ri for ri in rand] - inputforces = dict(follower_points=points, + mu_torsion = _interpolation_torsion[-1] + sigma_torsion = (1 + sigma0) * _interpolation_torsion[-1] + rand_torsion = np.random.normal(mu_torsion, sigma_torsion, paths) + follower_interpolation = [] + for i, ri in enumerate(rand): + interpolationrand = np.copy(interpolation) + interpolationrand[::2, -1] = ri + interpolationrand[1::2, -1] = rand_torsion[i] + follower_interpolation.append(interpolationrand) + #follower_interpolation = [interpolation * ri for ri in rand] + follower_points = [points]*paths + inputforces = dict(follower_points=follower_points, follower_interpolation=follower_interpolation ) inp.system.shard = dict(input_type="pointforces", inputs=inputforces) sol = feniax.feniax_shardmain.main(input_dict=inp, device_count=8) + # np.mean(sol.staticsystem_sys1.ra[:,-1,2,35]) + # np.std(sol.staticsystem_sys1.ra[:,-1,2,35]) +#+end_src +**** Plot results + +#+NAME: 3Dstatic +#+begin_src python :session *pyshard4* + import feniax.plotools.reconstruction as reconstruction + import feniax.preprocessor.configuration as configuration + config = configuration.Config(inp) + rintrinsic, uintrinsic = reconstruction.rbf_based( + nastran_bdf="./NASTRAN/BUG103.bdf", + X=config.fem.X, + time=range(len(inp.system.t)), + ra=sol.staticsystem_sys1.ra[0], + Rab=sol.staticsystem_sys1.Cab[0], + R0ab=sol.modes.C0ab, + vtkpath=inp.driver.sol_path / "paraview/bug", + plot_timeinterval=1, + plot_ref=True, + tolerance=1e-3, + size_cards=8, + rbe3s_full=False, + ra_movie=None) #+end_src + *** Manoeuvre #+begin_src python :tangle ./settings_manoeuvre1shard.py :session *pyshard1* <>