pyNastran  0.5.0
pyNastran BDF Reader/Writer, OP2 Parser, and GUI
springs.py
Go to the documentation of this file.
00001 ## GNU Lesser General Public License
00002 ## 
00003 ## Program pyNastran - a python interface to NASTRAN files
00004 ## Copyright (C) 2011-2012  Steven Doyle, Al Danial
00005 ## 
00006 ## Authors and copyright holders of pyNastran
00007 ## Steven Doyle <mesheb82@gmail.com>
00008 ## Al Danial    <al.danial@gmail.com>
00009 ## 
00010 ## This file is part of pyNastran.
00011 ## 
00012 ## pyNastran is free software: you can redistribute it and/or modify
00013 ## it under the terms of the GNU Lesser General Public License as published by
00014 ## the Free Software Foundation, either version 3 of the License, or
00015 ## (at your option) any later version.
00016 ## 
00017 ## pyNastran is distributed in the hope that it will be useful,
00018 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 ## GNU General Public License for more details.
00021 ## 
00022 ## You should have received a copy of the GNU Lesser General Public License
00023 ## along with pyNastran.  If not, see <http://www.gnu.org/licenses/>.
00024 ## 
00025 # pylint: disable=C0103,R0902,R0904,R0914
00026 
00027 from __future__ import division, print_function
00028 
00029 import sys
00030 #from numpy import zeros,pi
00031 
00032 from pyNastran.bdf.fieldWriter import set_blank_if_default
00033 from pyNastran.bdf.cards.baseCard import Property
00034 
00035 class SpringProperty(Property):
00036     type = 'SpringProperty'
00037     def __init__(self, card, data):
00038         Property.__init__(self, card, data)
00039         pass
00040 
00041 class PELAS(SpringProperty):
00042     type = 'PELAS'
00043     def __init__(self,card=None,nPELAS=0,data=None):
00044         SpringProperty.__init__(self, card, data)
00045         nOffset = nPELAS*5
00046         if card:
00047             self.pid = card.field(1+nOffset) # 2 PELAS properties can be defined on 1 PELAS card
00048             self.k   = card.field(2+nOffset) # these are split into 2 separate cards
00049             self.ge  = card.field(3+nOffset,0.)
00050             self.s   = card.field(4+nOffset,0.)
00051         else:
00052             self.pid = data[0]
00053             self.k   = data[1]
00054             self.ge  = data[2]
00055             self.s   = data[3]
00056         ###
00057 
00058     def crossReference(self,model):
00059         #if self.sol in [108,129]:
00060             #self.pid = self.pelasts[self.pid]
00061         pass
00062         
00063     def writeCodeAster(self):
00064         """
00065         @todo check if there are 1 (DISCRET=>K_T_D_N) or 2 (DISCRET_2D=>K_T_D_L) nodes
00066         """
00067         nodes = self.nodeIDs()
00068         msg = ''
00069         msg += 'DISCRET=_F( # PELAS\n'
00070         if nodes[0]:
00071             msg += "     CARA='K_T_D_N'\n"
00072             msg += "     GROUP_MA=P_%s\n" %(self.Pid())
00073             msg += "     NOEUD=N%i,\n" % (nodes[0])
00074 
00075         if nodes[1]:
00076             msg += "     CARA='K_T_D_L'\n"
00077             msg += "     NOEUD=N%i,\n" % (nodes[1])
00078             msg += "     AMOR_HYST=%g # ge - damping\n" % (self.ge)
00079         msg += "     )\n"
00080         msg += "\n"
00081         
00082         if self.c1 == 1:  ## @todo what is this???
00083             msg += "VALE=(%g,0.,0.)\n" %(self.k)
00084         elif self.c1 == 2:
00085             msg += "VALE=(0.,%g,0.)\n" %(self.k)
00086         elif self.c1 == 2:
00087             msg += "VALE=(0.,0.,%g)\n" %(self.k)
00088         else:
00089             raise ValueError('unsupported value of c1=%s' % (self.c1))
00090         ###
00091         return msg
00092 
00093     def rawFields(self):
00094         fields = ['PELAS', self.pid, self.k, self.ge, self.s]
00095         return fields
00096 
00097     def reprFields(self):
00098         ge = set_blank_if_default(self.ge, 0.)
00099         s  = set_blank_if_default(self.s, 0.)
00100         fields = ['PELAS', self.pid, self.k, ge, s]
00101         return fields
00102 
00103 class PELAST(SpringProperty):
00104     """
00105     Frequency Dependent Elastic Property
00106     Defines the frequency dependent properties for a PELAS Bulk Data entry.
00107     
00108     The PELAST entry is ignored in all solution sequences except frequency
00109     response (108) or nonlinear analyses (129).
00110     """
00111     type = 'PELAST'
00112     def __init__(self,card=None,nPELAS=0,data=None):
00113         SpringProperty.__init__(self, card, data)
00114         self.pid   = card.field(1)
00115         ## Identification number of a TABLEDi entry that defines the force per unit
00116         ## displacement vs. frequency relationship. (Integer > 0; Default = 0)
00117         self.tkid  = card.field(2,0)
00118         ## Identification number of a TABLEDi entry that defines the
00119         ## nondimensional structural damping coefficient vs. frequency
00120         ## relationship. (Integer > 0; Default = 0)
00121         self.tgeid = card.field(3,0)
00122         ## Identification number of a TABELDi entry that defines the nonlinear
00123         ## force vs. displacement relationship. (Integer > 0; Default = 0)
00124         self.tknid = card.field(4,0)
00125 
00126     def crossReference(self,model):
00127         self.pid = model.Property(self.pid)
00128         if self.tkid>0:
00129             self.tkid  = model.Table(self.tkid)
00130         if self.tgeid>0:
00131             self.tgeid = model.Table(self.tgeid)
00132         if self.tknid>0:
00133             self.tknid = model.Table(self.tknid)
00134         ###
00135     
00136     def Pid(self):
00137         if isinstance(self.pid,int):
00138             return self.pid
00139         return self.pid.pid
00140 
00141     def Tkid(self):
00142         if isinstance(self.tkid,int):
00143             return self.tkid
00144         return self.tkid.tid
00145 
00146     def Tknid(self):
00147         if isinstance(self.tknid,int):
00148             return self.tknid
00149         return self.tknid.tid
00150 
00151     def Tgeid(self):
00152         if isinstance(self.tgeid,int):
00153             return self.tgeid
00154         return self.tgeid.tid
 All Classes Namespaces Files Functions Variables