def correctPrestrain(self, sol, inst): from Cata.cata import POST_RELEVE_T, DETRUIRE, DEFI_FONCTION from Accas import _F tabfor = POST_RELEVE_T(ACTION=(_F(OPERATION='EXTRACTION', INTITULE='forc', RESULTAT=sol, NOM_CHAM='SIEF_ELNO', INST=(inst), GROUP_NO=(self.beamhead), NOM_CMP=( 'N', 'VY', 'VZ', 'MT', 'MFY', 'MFZ', )))) Fax = tabfor['N', 1] mult = self.Fv / Fax self.dt *= mult print "Bolt ", self.label, ": force Fax = ", Fax, ", resulting multiplier = ", mult blT = BoltedJoint.allTempRamps # re-create temperature ramp for beams DETRUIRE(CONCEPT=(_F(NOM=blT[self.label]), _F(NOM=tabfor)), INFO=1) blT[self.label] = DEFI_FONCTION(NOM_PARA='INST', VALE=(0, 0, self.steps, -self.dt), INTERPOL='LIN', PROL_DROITE='CONSTANT', PROL_GAUCHE='CONSTANT')
def area(mesh, group_ma_name): from Cata.cata import CREA_MAILLAGE, AFFE_MODELE, DEFI_MATERIAU, \ AFFE_MATERIAU, AFFE_CARA_ELEM, POST_ELEM, DETRUIRE from Accas import _F tmpmesh = CREA_MAILLAGE( MAILLAGE=mesh, MODI_MAILLE=_F( GROUP_MA=group_ma_name, OPTION='TRIA6_7', #PREF_NOEUD='NT' )) dummod = AFFE_MODELE( MAILLAGE=tmpmesh, #VERIF='MAILLE', AFFE=( _F( GROUP_MA=(group_ma_name), # '1out', '2in'), PHENOMENE='MECANIQUE', MODELISATION='COQUE_3D'), ), ) dummat = DEFI_MATERIAU(ELAS=_F( E=210000.0, RHO=1, NU=0.0, ), ) dmatass = AFFE_MATERIAU( MAILLAGE=tmpmesh, AFFE=_F( GROUP_MA=group_ma_name, MATER=dummat, ), ) tmpcara = AFFE_CARA_ELEM( MODELE=dummod, COQUE=_F( GROUP_MA=group_ma_name, EPAIS=1.0, ), ) tmptab = POST_ELEM( MASS_INER=_F(GROUP_MA=group_ma_name), CARA_ELEM=tmpcara, TITRE='tit_von_post_elem', MODELE=dummod, CHAM_MATER=dmatass, ) #IMPR_TABLE(TABLE=tab_post,); print tmptab.EXTR_TABLE() A = tmptab['MASSE', 1] DETRUIRE(CONCEPT=(_F(NOM=(tmpmesh, dummod, dummat, dmatass, tmpcara, tmptab))), INFO=1) return A
def readMeshes(nMeshes): from Cata.cata import LIRE_MAILLAGE, ASSE_MAILLAGE, DETRUIRE from Accas import _F # read and assemble nMeshes mesh files (names are given in astk) m = [None] * nMeshes mesh = None for i in range(0, nMeshes): if i > 0: addmesh = LIRE_MAILLAGE(UNITE=20 + i, FORMAT='MED') m[i] = ASSE_MAILLAGE(MAILLAGE_1=m[i - 1], MAILLAGE_2=addmesh, OPERATION='SUPERPOSE') DETRUIRE(CONCEPT=(_F(NOM=(m[i - 1], addmesh))), INFO=1) else: m[i] = LIRE_MAILLAGE(UNITE=20 + i, FORMAT='MED') return m[nMeshes - 1]
def volume(mesh, group_ma_name): from Cata.cata import CREA_MAILLAGE, AFFE_MODELE, DEFI_MATERIAU, \ AFFE_MATERIAU, AFFE_CARA_ELEM, POST_ELEM, DETRUIRE from Accas import _F dummod = AFFE_MODELE( MAILLAGE=mesh, # VERIF='MAILLE', AFFE=( _F( GROUP_MA=(group_ma_name), # '1out', '2in'), PHENOMENE='MECANIQUE', MODELISATION='3D'), ), ) dummat = DEFI_MATERIAU(ELAS=_F( E=210000.0, RHO=1, NU=0.0, ), ) dmatass = AFFE_MATERIAU( MAILLAGE=mesh, AFFE=_F( GROUP_MA=group_ma_name, MATER=dummat, ), ) tmptab = POST_ELEM( MASS_INER=_F(GROUP_MA=group_ma_name), TITRE='tit_von_post_elem', MODELE=dummod, CHAM_MATER=dmatass, ) #IMPR_TABLE(TABLE=tab_post,); print tmptab.EXTR_TABLE() V = tmptab['MASSE', 1] DETRUIRE(CONCEPT=(_F(NOM=(dummod, dummat, dmatass, tmptab))), INFO=1) return V
def writeDisplacements(self, sol, instant): from Cata.cata import POST_RELEVE_T, DETRUIRE from Accas import _F force = POST_RELEVE_T( ACTION=( _F( OPERATION='EXTRACTION', INTITULE='force', RESULTAT=sol, NOM_CHAM='FORC_NODA', INST=(instant), GROUP_NO=self.femname, RESULTANTE=('DX', 'DY', 'DZ'), #TOUT_CMP='OUI' ), ), ) ft = force.EXTR_TABLE().values() print "applied force=", ft['DX'][0], ft['DY'][0], ft['DZ'][0] DETRUIRE(CONCEPT=(_F(NOM=(force))), INFO=1) # extract displacements of coupled boundaries utab = POST_RELEVE_T(ACTION=( _F( OPERATION='EXTRACTION', INTITULE='disp', RESULTAT=sol, NOM_CHAM='DEPL', INST=(instant), #GROUP_NO=('v_2', 'v_3'), GROUP_NO=self.femname, TOUT_CMP='OUI'))) u = utab.EXTR_TABLE().values() uinterp_pts = np.asarray(zip(u['COOR_X'], u['COOR_Y'], u['COOR_Z'])) disp = np.asarray(zip(u['DX'], u['DY'], u['DZ'])) if self.debug: f = open( os.path.join(self.scratchdircomm.scratchdir, "dbg.FEMlocations." + self.cfdname), "w") for p in uinterp_pts: f.write("%g;%g;%g\n" % (p[0], p[1], p[2])) f.close() f = open( os.path.join(self.scratchdircomm.scratchdir, "dbg.FEMdisplacements." + self.cfdname), "w") for u in disp: f.write("%g;%g;%g\n" % (u[0], u[1], u[2])) f.close() uinterp = spi.NearestNDInterpolator(uinterp_pts, disp) u_pts = [uinterp(p[0], p[1], p[2]) for p in self.pts] print "Pair %s/%s: min cmpt="%(self.cfdname,self.femname), \ np.min(u_pts), "max cmpt=", np.max(u_pts) f = open( os.path.join(self.scratchdircomm.scratchdir, "displacements." + self.cfdname), 'w') f.write("(\n") for j, u in enumerate(u_pts): f.write("(%g %g %g)\n" % (u[0], u[1], u[2])) f.write(")\n") f.flush() os.fsync(f.fileno()) f.close() DETRUIRE(CONCEPT=(_F(NOM=(utab))), INFO=1)
def extractReactionForces(self, label, singlenode_groups, cumulnode_groups, s): from Cata.cata import POST_RELEVE_T, CALC_TABLE, IMPR_TABLE, DETRUIRE from Accas import _F ops = [] ops2 = [] for gname in singlenode_groups: ops.append( _F( OPERATION='EXTRACTION', INTITULE=gname, RESULTAT=s, NOM_CHAM='REAC_NODA', GROUP_NO=gname, RESULTANTE=('DX', 'DY', 'DZ', 'DRX', 'DRY', 'DRZ'), )) ops2.append( _F(OPERATION='EXTRACTION', INTITULE=gname, RESULTAT=s, NOM_CHAM='DEPL', GROUP_NO=gname, NOM_CMP=( 'DX', 'DY', 'DZ', ))) for gname, center in cumulnode_groups: ops.append( _F(OPERATION='EXTRACTION', INTITULE=gname, RESULTAT=s, NOM_CHAM='REAC_NODA', GROUP_NO=gname, RESULTANTE=( 'DX', 'DY', 'DZ', ), MOMENT=('DRX', 'DRY', 'DRZ'), POINT=center), ) reac = POST_RELEVE_T(ACTION=tuple(ops)) deplta = POST_RELEVE_T(ACTION=tuple(ops2)) IMPR_TABLE( TABLE=reac, FORMAT='TABLEAU', ) IMPR_TABLE( TABLE=deplta, FORMAT='TABLEAU', ) csvsnippet = "#name,X,Y,Z,FX,FY,FZ,MX,MY,MZ\n" # all in N and mm latexsnippet="""\\begin{tabular}{lrrrrrr} ID & $F_x/N$ & $F_y/N$ & $F_z/N$ & $M_x/Nm$ & $M_y/Nm$ & $M_z/Nm$\\\\ \\hline """ ## convert Nmm into Nm!! i = 0 for gname in singlenode_groups: i += 1 csvsnippet += "%s,%g,%g,%g,%g,%g,%g,%g,%g,%g\n" % ( gname, deplta['COOR_X', i], deplta['COOR_Y', i], deplta['COOR_Z', i], reac['DX', i], reac['DY', i], reac['DZ', i], reac['DRX', i], reac['DRY', i], reac['DRZ', i]) latexsnippet += "%s & %.2f & %.2f & %.2f & %.2f & %.2f & %.2f\\\\\n" % ( gname, reac['DX', i], reac['DY', i], reac['DZ', i], 1e-3 * reac['DRX', i], 1e-3 * reac['DRY', i], 1e-3 * reac['DRZ', i]) for gname, center in cumulnode_groups: i += 1 csvsnippet += "%s,%g,%g,%g,%g,%g,%g,%g,%g,%g\n" % ( gname, center[0], center[1], center[2], reac['RESULT_X', i], reac['RESULT_Y', i], reac['RESULT_Z', i], reac['MOMENT_X', i], reac['MOMENT_Y', i], reac['MOMENT_Z', i]) latexsnippet += "%s & %.2f & %.2f & %.2f & %.2f & %.2f & %.2f\\\\\n" % ( gname, reac['RESULT_X', i], reac['RESULT_Y', i], reac['RESULT_Z', i], 1e-3 * reac['MOMENT_X', i], 1e-3 * reac['MOMENT_Y', i], 1e-3 * reac['MOMENT_Z', i]) latexsnippet += "\\end{tabular}\n" self.appendFile(label + "_table.csv", csvsnippet) self.appendFile(label + "_table.tex", latexsnippet) DETRUIRE( CONCEPT=_F(NOM=(reac, deplta), ), INFO=1, )
def extractMaxShellStress(self, label, group, solInf, solSup): from Cata.cata import POST_RELEVE_T, CALC_TABLE, IMPR_TABLE, DETRUIRE from Accas import _F critset = 'SIEQ_ELNO' critcmp = 'VMIS' repset = 'SIEQ_ELNO' repcmp = ('VMIS', 'PRIN_1', 'PRIN_2', 'PRIN_3', 'VECT_1_X', 'VECT_1_Y', 'VECT_1_Z', 'VECT_2_X', 'VECT_2_Y', 'VECT_2_Z', 'VECT_3_X', 'VECT_3_Y', 'VECT_3_Z') vmis = 0. sigma123 = [0., 0., 0.] pt = [0., 0., 0.] for s in [solInf, solSup]: tabmax = POST_RELEVE_T( ACTION=_F( INTITULE='extremes', OPERATION='EXTREMA', GROUP_MA=group, RESULTAT=s, NOM_CHAM=critset, NOM_CMP=(critcmp, ), #LIST_INST = ( liste , ) , ), ) tabmax = CALC_TABLE( TABLE=tabmax, reuse=tabmax, ACTION=( _F( OPERATION='FILTRE', NOM_PARA='EXTREMA', VALE_K='MAX', ), _F( OPERATION='TRI', NOM_PARA='VALE', ORDRE='CROISSANT', ), ), ) thiselem = tabmax['MAILLE', 1] thisnode = tabmax['NOEUD', 1] valatmax = POST_RELEVE_T(ACTION=_F(INTITULE=label, OPERATION='EXTRACTION', RESULTAT=s, NOM_CHAM=repset, MAILLE=thiselem, NOEUD=thisnode, NOM_CMP=repcmp), ) IMPR_TABLE(TABLE=valatmax) cur_vmis = valatmax['VMIS', 1] if (abs(cur_vmis) > vmis): vmis = cur_vmis sigma123 = [ valatmax['PRIN_1', 1], valatmax['PRIN_2', 1], valatmax['PRIN_3', 1] ] pt = [ valatmax['COOR_X', 1], valatmax['COOR_Y', 1], valatmax['COOR_Z', 1] ] DETRUIRE(CONCEPT=_F(NOM=(tabmax, valatmax)), ) snippet = """<?xml version="1.0" encoding="utf-8"?> <root> <selectableSubset name="witnesspointlocation" value="localparentmaterial"> <double name="S1" value="%g"/> <double name="S2" value="%g"/> <double name="S3" value="%g"/> </selectableSubset> </root> """ % (sigma123[0], sigma123[1], sigma123[2]) self.appendFile(label + "_stress_values.ist", snippet) snippet = """ sphere1 = Sphere() # Properties modified on sphere1 sphere1.Center = [%g, %g, %g] sphere1.Radius = 50 for view in GetRenderViews(): sphere1Display = Show(sphere1, view) sphere1Display.DiffuseColor = [1.0, 0.0, 0.0] """ % (pt[0], pt[1], pt[2]) self.appendFile(label + "_paraview_asp_marker.py", snippet)
def extractMaxBeamStress(self, label, group, s): from Cata.cata import POST_RELEVE_T, CALC_TABLE, IMPR_TABLE, DETRUIRE from Accas import _F tabex = POST_RELEVE_T(ACTION=tuple([ _F( INTITULE=label + ':' + qty, OPERATION='EXTREMA', GROUP_MA=group, RESULTAT=s, NOM_CHAM='SIPO_ELNO', NOM_CMP=(qty, ), ) for qty in ['SN', 'SVY', 'SVZ', 'SMT', 'SMFY', 'SMFZ'] ])) tabmax = CALC_TABLE( TABLE=tabex, ACTION=(_F( OPERATION='FILTRE', NOM_PARA='EXTREMA', VALE_K='MAX', ), ), ) IMPR_TABLE(TABLE=tabmax) tabmin = CALC_TABLE( TABLE=tabex, ACTION=(_F( OPERATION='FILTRE', NOM_PARA='EXTREMA', VALE_K='MIN', ), ), ) IMPR_TABLE(TABLE=tabmin) extrema = {} for cm, i in [('SN', 1), ('SVY', 2), ('SVZ', 3), ('SMT', 4), ('SMFY', 5), ('SMFZ', 6)]: minv = tabmin['VALE', i] maxv = tabmax['VALE', i] ex = maxv if (abs(minv) > abs(maxv)): ex = minv extrema[cm] = ex DETRUIRE(CONCEPT=_F(NOM=(tabmax, tabmin, tabex)), ) snippet = """<?xml version="1.0" encoding="utf-8"?> <root> <selectableSubset name="witnesspointlocation" value="nominalparentmaterial"> <double name="Szd" value="%g"/> <double name="Tsy" value="%g"/> <double name="Tsz" value="%g"/> <double name="Tt" value="%g"/> <double name="Sby" value="%g"/> <double name="Sbz" value="%g"/> </selectableSubset> </root> """ % (extrema['SN'], extrema['SVY'], extrema['SVZ'], extrema['SMT'], extrema['SMFY'], extrema['SMFZ']) self.appendFile(label + "_stress_values.ist", snippet)
def evaluate(self, sol, inst_prestressed, inst_fullyloaded): from Cata.cata import POST_RELEVE_T, DETRUIRE, DEFI_FONCTION from Accas import _F data = [] for inst in [inst_prestressed, inst_fullyloaded]: tabfor = POST_RELEVE_T(ACTION=(_F(OPERATION='EXTRACTION', INTITULE='forc', RESULTAT=sol, NOM_CHAM='SIEF_ELNO', INST=(inst), GROUP_NO=(self.beamhead), NOM_CMP=( 'N', 'VY', 'VZ', 'MT', 'MFY', 'MFZ', )))) print tabfor.EXTR_TABLE() tabuh = POST_RELEVE_T(ACTION=(_F(OPERATION='EXTRACTION', INTITULE='disph', RESULTAT=sol, NOM_CHAM='DEPL', INST=(inst), GROUP_NO=(self.beamhead), NOM_CMP=( 'DX', 'DY', 'DZ', )))) print tabuh.EXTR_TABLE() tabun = POST_RELEVE_T(ACTION=(_F(OPERATION='EXTRACTION', INTITULE='dispn', RESULTAT=sol, NOM_CHAM='DEPL', INST=(inst), GROUP_NO=(self.beamnut), NOM_CMP=( 'DX', 'DY', 'DZ', )))) # get longitudinal direction of screw xh = np.array( [tabuh['COOR_X', 1], tabuh['COOR_Y', 1], tabuh['COOR_Z', 1]]) xn = np.array( [tabun['COOR_X', 1], tabun['COOR_Y', 1], tabun['COOR_Z', 1]]) r = xh - xn r /= np.linalg.norm(r) Fax = tabfor['N', 1] uh = np.array([tabuh['DX', 1], tabuh['DY', 1], tabuh['DZ', 1]]) un = np.array([tabun['DX', 1], tabun['DY', 1], tabun['DZ', 1]]) data.append([ Fax, uh, un, np.dot(uh, r), np.dot(un, r), np.dot(uh, r) - np.dot(un, r) ]) DETRUIRE(CONCEPT=(_F(NOM=(tabfor, tabuh, tabun))), INFO=1) print data delta_L = np.linalg.norm(uh - un) print "Bolt ", self.label, ": force = ", Fax, ", uh=", uh, ", un=", un, ", delta_L=", delta_L f_T = np.linalg.norm( data[0] [5]) # deformation in unload but prestressed state equals f_T F_V = data[0][0] # prestress force F_BS = data[1][0] - F_V # maximum screw force Delta_f = data[1][5] - data[0][ 5] # length change between prestressed state and fully loaded state delta_S = Delta_f / F_BS # elasticity of screw delta_T = f_T / F_V # elasticity of part return F_V, data[1][0], F_BS, delta_S, delta_T, Delta_f