NGsolveCreateFFRFreducedOrder.py

You can view and download this file on Github: NGsolveCreateFFRFreducedOrder.py

 1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2# This is an EXUDYN example
 3#
 4# Details:  New CreateFFRFReducedOrderObject function using NGsolve and ObjectGenericODE2;
 5#           uses super-functions to simplify creating of flexible bodies
 6#
 7# Author:   Sebastian Weyrer, Johannes Gerstmayr
 8# Date:     2025-12-27
 9#
10# Copyright:This file is part of Exudyn. Exudyn is free software. You can redistribute it and/or modify it under the terms of the Exudyn license. See 'LICENSE.txt' for more details.
11#
12#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
14
15import exudyn as exu
16from exudyn.itemInterface import *
17from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
18import exudyn.graphics as graphics #only import if it does not conflict
19from exudyn.FEM import *
20from exudyn.graphicsDataUtilities import *
21
22SC = exu.SystemContainer()
23mbs = SC.AddSystem()
24
25import numpy as np
26
27import exudyn as exu
28import exudyn.graphics as graphics
29from exudyn.FEM import * # includes fem functionality
30from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
31from netgen import occ
32import ngsolve as ngs
33SC = exu.SystemContainer()
34mbs = SC.AddSystem()
35
36materials = {'steel':{'youngsModulus':2e11, 'poissonsRatio':0.3, 'density':7850}}
37L = 1
38W = 0.1
39cuboid = occ.Box((0, -W/2, -W/2), (L, W/2, W/2))
40boundaryNamesList = ['boundary0', 'boundary1']
41cuboid.faces.Min((1, 0, 0)).name = boundaryNamesList[0]
42cuboid.faces.Max((1, 0, 0)).name = boundaryNamesList[1]
43cuboid.name = 'steel'
44geo = occ.OCCGeometry(cuboid)
45
46mesh = ngs.Mesh(geo.GenerateMesh(maxh=0.025))
47
48cuboidFemInterface = FEMinterface()
49cuboidFemInterface.ImportMeshFromNGsolve(mesh=mesh,
50                                         materials=materials,
51                                         boundaryNamesList=boundaryNamesList,
52                                         meshOrder=1)
53[boundaryNodesList, boundaryWeightsList] = cuboidFemInterface.GetBoundaryNodeSetsAsLists()
54cuboidFemInterface.ComputeHurtyCraigBamptonModes(boundaryNodesList=boundaryNodesList,
55                                                 nEigenModes=6,
56                                                 boundaryNodesWeights=boundaryWeightsList)
57createFFRFObjectDict0 = mbs.CreateFFRFReducedOrderObject(name='cuboid0',
58                                                        femInterface=cuboidFemInterface,
59                                                        gravity=[0,0,-9.81])
60mBoundary00 = createFFRFObjectDict0['cuboid0:boundary0']
61mBoundary01 = createFFRFObjectDict0['cuboid0:boundary1']
62
63createFFRFObjectDict1 = mbs.CreateFFRFReducedOrderObject(name='cuboid1',
64                                                        femInterface=cuboidFemInterface,
65                                                        referencePosition=[L,0,0],
66                                                        gravity=[0,0,-9.81])
67mBoundary10 = createFFRFObjectDict1['cuboid1:boundary0']
68mBoundary11 = createFFRFObjectDict1['cuboid1:boundary1']
69
70gGround = graphics.CheckerBoard(point=[0,0,-2.5], size=8, nTiles=10, normal=[0.,0,1])
71oGround = mbs.CreateGround(referencePosition=[0,0,0],
72                           graphicsDataList=[gGround])
73
74#joints:
75mbs.CreateSphericalJoint(bodyNumbers=[mBoundary00, oGround], jointRadius = W/4)
76mbs.CreateSphericalJoint(bodyNumbers=[mBoundary01, mBoundary10], jointRadius = W/4)
77
78mbs.Assemble()
79simulationSettings = exu.SimulationSettings() #takes currently set values or default values
80simulationSettings.timeIntegration.numberOfSteps = 1000
81simulationSettings.timeIntegration.endTime = 2
82SC.visualizationSettings.nodes.show = False
83SC.visualizationSettings.openGL.light0.shadow = 0.2
84SC.visualizationSettings.openGL.multiSampling = 2
85
86SC.renderer.Start()
87if 'renderState' in exu.sys: SC.renderer.SetState(exu.sys['renderState']) #load last model view
88
89SC.renderer.DoIdleTasks() #press space to continue
90
91mbs.SolveDynamic(simulationSettings)
92
93SC.renderer.Stop() #safely close rendering window!
94
95mbs.SolutionViewer()