4343
4444class ImposedMotionFunction :
4545
46- def __init__ (self ,time0 ,tipo ,parameters ):
46+ def __init__ (self ,time0 ,typeOfMotion ,parameters ,mode ):
47+
4748 self .time0 = time0
48- self .tipo = tipo
49- if self .tipo == "SINUSOIDAL" :
50- self .bias = parameters [0 ]
51- self .amplitude = parameters [1 ]
52- self .frequency = parameters [2 ]
53- self .timeStart = parameters [3 ]
54-
55- elif self .tipo == "BLENDED_STEP" :
56- self .kmax = parameters [0 ]
57- self .vinf = parameters [1 ]
58- self .lref = parameters [2 ]
59- self .amplitude = parameters [3 ]
60- self .timeStart = parameters [4 ]
49+ self .typeOfMotion = typeOfMotion
50+ self .mode = mode
51+
52+ if self .typeOfMotion == "SINUSOIDAL" :
53+ self .bias = parameters ["BIAS" ]
54+ self .amplitude = parameters ["AMPLITUDE" ]
55+ self .frequency = parameters ["FREQUENCY" ]
56+ self .timeStart = parameters ["TIME_0" ]
57+
58+ elif self .typeOfMotion == "BLENDED_STEP" :
59+ self .kmax = parameters ["K_MAX" ]
60+ self .vinf = parameters ["V_INF" ]
61+ self .lref = parameters ["L_REF" ]
62+ self .amplitude = parameters ["AMPLITUDE" ]
63+ self .timeStart = parameters ["TIME_0" ]
6164 self .tmax = 2 * pi / self .kmax * self .lref / self .vinf
6265 self .omega0 = 1 / 2 * self .kmax
6366
@@ -67,10 +70,10 @@ def __init__(self,time0,tipo,parameters):
6770
6871 def GetDispl (self ,time ):
6972 time = time - self .time0 - self .timeStart
70- if self .tipo == "SINUSOIDAL" :
73+ if self .typeOfMotion == "SINUSOIDAL" :
7174 return self .bias + self .amplitude * sin (2 * pi * self .frequency * time )
7275
73- if self .tipo == "BLENDED_STEP" :
76+ if self .typeOfMotion == "BLENDED_STEP" :
7477 if time < 0 :
7578 return 0.0
7679 elif time < self .tmax :
@@ -81,10 +84,10 @@ def GetDispl(self,time):
8184 def GetVel (self ,time ):
8285 time = time - self .time0 - self .timeStart
8386
84- if self .tipo == "SINUSOIDAL" :
87+ if self .typeOfMotion == "SINUSOIDAL" :
8588 return self .amplitude * cos (2 * pi * self .frequency * time )* 2 * pi * self .frequency
8689
87- if self .tipo == "BLENDED_STEP" :
90+ if self .typeOfMotion == "BLENDED_STEP" :
8891 if time < 0 :
8992 return 0.0
9093 elif time < self .tmax :
@@ -94,10 +97,10 @@ def GetVel(self,time):
9497 def GetAcc (self ,time ):
9598 time = time - self .time0 - self .timeStart
9699
97- if self .tipo == "SINUSOIDAL" :
100+ if self .typeOfMotion == "SINUSOIDAL" :
98101 return - self .amplitude * sin (2 * pi * self .frequency * time )* (2 * pi * self .frequency )** 2
99102
100- if self .tipo == "BLENDED_STEP" :
103+ if self .typeOfMotion == "BLENDED_STEP" :
101104 if time < 0 :
102105 return 0.0
103106 elif time < self .tmax :
@@ -289,7 +292,7 @@ def __init__(self, config_fileName, ImposedMotion):
289292 self .markers = {}
290293 self .refsystems = []
291294 self .ImposedMotionToSet = True
292- self .ImposedMotionFunction = {}
295+ self .ImposedMotionFunction = []
293296
294297 print ("\n " )
295298 print (" Reading the mesh " .center (80 ,"-" ))
@@ -733,14 +736,17 @@ def __temporalIteration(self,time):
733736 This method integrates in time the solution.
734737 """
735738
739+ self .__reset (self .q )
740+ self .__reset (self .qdot )
741+ self .__reset (self .qddot )
742+ self .__reset (self .a )
743+
736744 if not self .ImposedMotion :
737745 eps = 1e-6
738746
739747 self .__SetLoads ()
740748
741749 # Prediction step
742- self .__reset (self .qddot )
743- self .__reset (self .a )
744750
745751 self .a += (self .alpha_f )/ (1 - self .alpha_m )* self .qddot_n
746752 self .a -= (self .alpha_m )/ (1 - self .alpha_m )* self .a_n
@@ -768,14 +774,20 @@ def __temporalIteration(self,time):
768774 self .a += (1 - self .alpha_f )/ (1 - self .alpha_m )* self .qddot
769775 else :
770776 if self .ImposedMotionToSet :
771- for imode in self .Config ["IMPOSED_MODES" ].keys ():
772- self .ImposedMotionFunction [imode ] = ImposedMotionFunction (time ,self .Config ["IMPOSED_MODES" ][imode ],self .Config ["IMPOSED_PARAMETERS" ][imode ])
773- self .ImposedMotionToSet = False
774- for imode in self .Config ["IMPOSED_MODES" ].keys ():
775- self .q [imode ] = self .ImposedMotionFunction [imode ].GetDispl (time )
776- self .qdot [imode ] = self .ImposedMotionFunction [imode ].GetVel (time )
777- self .qddot [imode ] = self .ImposedMotionFunction [imode ].GetAcc (time )
778- self .a = np .copy (self .qddot )
777+ iImposedFunc = 0
778+ for imode in self .Config ["IMPOSED_MODES" ].keys ():
779+ for isuperposed in range (len (self .Config ["IMPOSED_MODES" ][imode ])):
780+ typeOfMotion = self .Config ["IMPOSED_MODES" ][imode ][isuperposed ]
781+ parameters = self .Config ["IMPOSED_PARAMETERS" ][imode ][isuperposed ]
782+ self .ImposedMotionFunction [iImposedFunc ] = ImposedMotionFunction (time , typeOfMotion , parameters , imode )
783+ iImposedFunc += 1
784+ self .ImposedMotionToSet = False
785+ for iImposedFunc in range (len (self .ImposedMotionFunction )):
786+ imode = self .ImposedMotionFunction [iImposedFunc ].mode
787+ self .q [imode ] += self .ImposedMotionFunction [iImposedFunc ].GetDispl (time )
788+ self .qdot [imode ] += self .ImposedMotionFunction [iImposedFunc ].GetVel (time )
789+ self .qddot [imode ] += self .ImposedMotionFunction [iImposedFunc ].GetAcc (time )
790+ self .a = np .copy (self .qddot )
779791
780792
781793 def __SetLoads (self ):
0 commit comments