def __init__(self, section=None, material=None, orientation=None, behavior=None, **kargs):

        ### sectiontype is now preferably an attribute of section ###

        """Create a new element section property. Empty by default.
        
        An element section property can hold the following sub-properties:
       - section: the section properties of the element. This can be a dict
          or a string. The required data in this dict depend on the
          sectiontype. Currently the following keys are used by fe_abq.py:
            - sectiontype: the type of section: one of following:
              'solid': a solid 2D or 3D section,
              'circ' : a plain circular section,
              'rect' : a plain rectangular section,
              'pipe' : a hollow circular section,
              'box'  : a hollow rectangular section,
              'I'    : an I-beam,
              'general' : anything else (automatically set if not specified).
              !! Currently only 'solid' and 'general' are allowed.
            - the cross section characteristics :
              cross_section, moment_inertia_11, moment_inertia_12,
              moment_inertia_22, torsional_rigidity
            - for sectiontype 'circ': radius
         - material: the element material. This can be a dict or a string.
          Currently known keys to fe_abq.py are:
            young_modulus, shear_modulus, density, poisson_ratio
        - 'orientation' is a list of 3 direction cosines of the first beam
          section axis.
        - behavior: the behavior of the connector
        """
        CDict.__init__(self, kargs)
        self.addMaterial(material)
        self.addSection(section)
示例#2
0
 def __init__(self,section=None,material=None,orientation=None,**kargs):
     """Create a new element section property. Empty by default."""
     if _matDB is None:
         setMaterialDB({})
     if _secDB is None:
         setSectionDB({})
     CDict.__init__(self, kargs)
     self.addMaterial(material)
     self.addSection(section)
     if orientation is not None:
         self.orientation = orientation
示例#3
0
    def Prop(self,kind='',tag=None,set=None,name=None,**kargs):
        """Create a new property, empty by default.

        A property can hold almost anything, just like any Dict type.
        It has however four predefined keys that should not be used for
        anything else than explained hereafter:

        - nr: a unique id, that never should be set/changed by the user.
        - tag: an identification tag used to group properties
        - name: the name to be used for this set. Default is to use an
          automatically generated name.
        - set: identifies the geometrical elements for which the defined
          properties will hold. This can be either:

          - a single number,
          - a list of numbers,
          - the name of an already defined set,
          - a list of such names.

        Besides these, any other fields may be defined and will be added
        without checking.
        """
        d = CDict()
        # update with kargs first, to make sure tag,set and nr are sane
        d.update(dict(**kargs))

        prop = getattr(self, kind+'prop')
        d.nr = len(prop)
        if tag is not None:
            d.tag = str(tag)
        if name is None and 'setname' in kargs:
            # allow for backwards compatibility
            pf.utils.warn("warn_properties_setname")
            name = setname
        if name is None and isinstance(set, str):
            ### convenience to allow set='name' as alias for name='name'
            ### to reuse already defined set
            name, set = set, name
        if name is None:
            name = self.autoName(kind, d.nr)
        elif not isinstance(name, str):
            raise ValueError("Property name should be a string")
        d.name = name
        if set is not None:
            if isinstance(set, int) or isinstance(set, str):
                set = [ set ]
            d.set = unique(set)

        prop.append(d)
        return d
示例#4
0
    def addMaterial(self, material):
        """Create or replace the material properties of the element.

        If the argument is a dict, it will be added to the global MaterialDB.
        If the argument is a string, this string will be used as a key to
        search in the global MaterialDB.
        """
        if isinstance(material, str) :
            if material in _matDB:
                self.material = _matDB[material]
            else:
                pf.warning("Material '%s'  is not in the database" % material)
        elif isinstance(material, dict):
            _matDB[material['name']] = CDict(material)
            self.material = _matDB[material['name']]
        elif material is None:
            self.material=material
        else:
            raise ValueError("Expected a string or a dict")
    def Prop(self, kind="", tag=None, set=None, setname=None, **kargs):
        """Create a new property, empty by default.

        A property can hold almost anything, just like any Dict type.
        It has however four predefined keys that should not be used for
        anything else than explained hereafter:
        - nr: a unique id, that never should be set/changed by the user.
        - tag: an identification tag used to group properties
        - set: a single number or a list of numbers identifying the geometrical
               elements for wich the property is set, or the name of a
               previously defined set.
        - setname: the name to be used for this set. Default is to use an
               automatically generated name. If setname is specified without
               a set, this is interpreted as a set= field.
        Besides these, any other fields may be defined and will be added
        without checking.
        """
        d = CDict()
        # update with kargs first, to make sure tag,set and nr are sane
        d.update(dict(**kargs))

        prop = getattr(self, kind + "prop")
        d.nr = len(prop)
        if tag is not None:
            d.tag = str(tag)
        if set is not None:
            if type(set) is str and setname is None:
                ### convenience to allow set='name' as alias for setname='name'
                ### to reuse already defined set
                set, setname = setname, set
            else:
                if type(set) is int:
                    set = [set]
                d.set = unique1d(set)
                if setname is None:
                    setname = self.autoName(kind, d.nr)
        if setname is not None:
            if type(setname) is not str:
                raise ValueError, "setname should be a string"
            d.setname = setname

        prop.append(d)
        return d
示例#6
0
    def addSection(self, section):
        """Create or replace the section properties of the element.

        If 'section' is a dict, it will be added to the global SectionDB.
        If 'section' is a string, this string will be used as a key to
        search in the global SectionDB.
        """
        if isinstance(section, str):
            if section in _secDB:
                self.section = _secDB[section]
            else:
                pf.warning("Section '%s' is not in the database" % section)
        elif isinstance(section, dict):
            # WE COULD ADD AUTOMATIC CALCULATION OF SECTION PROPERTIES
            #self.computeSection(section)
            #print(section)
            _secDB[section['name']] = CDict(section)
            self.section = _secDB[section['name']]
        elif section is None:
            self.section = section
        else:
            raise ValueError("Expected a string or a dict")
示例#7
0
##################################### Test ###########################

if __name__ == '__script__' or  __name__ == '__draw__':


    if pf.GUI:
        chdir(__file__)
    print(os.getcwd())

    P = PropertyDB()

    Stick = P.Prop(color='green', name='Stick', weight=25, comment='This could be anything: a gum, a frog, a usb-stick,...')
    print(Stick)

    author = P.Prop(tag='author', alias='Alfred E Neuman', address=CDict({'street':'Krijgslaan', 'city':'Gent','country':'Belgium'}))

    print(P.getProp(tag='author')[0])

    Stick.weight=30
    Stick.length=10
    print(Stick)

    print(author.street)
    author.street='Voskenslaan'
    print(author.street)
    print(author.address.street)
    author.address.street = 'Wiemersdreef'
    print(author.address.street)

    author = P.Prop(tag='author', name='John Doe', address={'city': 'London', 'street': 'Downing Street 10', 'country': 'United Kingdom'})
示例#8
0
def test_esetName():
    assert esetName(CDict()) == 'Eall'
    assert esetName(CDict({'name': 'myname'})) == 'myname'
示例#9
0
def test_nsetName():
    assert nsetName(CDict()) == 'Nall'
    assert nsetName(CDict({'name': 'myname'})) == 'myname'