Implementing new Material

Hi there,

I tried to implement a new material in the compas_fea library.

I’ve used the following Example for execution:

  • beam_simple.3dm

Steps of implementation:

1. Implementing of SolidwoodC24 in the python file:(It is based on predefined orthotropic Material)

class SolidwoodC24(Material):

""" Elastic, orthotropic and homogeneous material.
    Parameters According to SIA 265 & SIA 265/1, page 25 (dimensioning Niveau)

name : str
    Material name.
Ex = Ey : float
    Young's modulus Ex, Ey in x & y direction [Pa].
    Perpendicular to fiber direction. 
    According to local axis of cross section.
Ez : float
    Young's modulus Ez in z direction [Pa]. 
    Parallel to fiber direction.
    According to local axis of cross section. 
v   : float
    Poissons ratio --> unknown!
G   : float
    Mean shear modulus [Pa].
p   : float
    Density [kg/m3].
tension : bool
    Can take tension.
compression : bool
    Can take compression.
type: C16, C24, C30, D30 
    According to SIA 256 & SIA 265/1
    C24 as default value. --> not implemented yet!!
fu  : float
    Ultimate stresses --> not yet defined!!


def __init__(self, name, Ex=300, Ey=300, Ez=11000, vxy=0.3, vyz=0.3, vzx=0.3, Gxy=500, Gyz=500, Gzx=500, p=380, tension=True, compression=True):
    Material.__init__(self, name=name)

    Ex *= 10.**6; Ey *= 10.**6; Ez *= 10.**6; Gxy *= 10.**6; Gyz *= 10.**6; Gzx *= 10.**6

    self.__name__    = 'SolidwoodC24'        = name
    self.E           = {'Ex': Ex, 'Ey': Ey, 'Ez': Ez}
    self.v           = {'vxy': vxy, 'vyz': vyz, 'vzx': vzx}
    self.G           = {'Gxy': Gxy, 'Gyz': Gyz, 'Gzx': Gzx}
    self.p           = p
    self.tension     = tension
    self.compression = compression
    self.attr_list.extend(['E', 'v', 'G', 'p', 'tension', 'compression'])

1.1 This command line works in the PythonRhinoScript:
from compas_fea.structure import SolidwoodC24
1.2 If I try to assemble the new material to the structure through the following command line
(in PythonRhinoScript):

–>Then I get an error message:image

2. In a second step, I additional tried to implement the recently created material in the following python file:

2.1 By executing the example again, I got several new error messages:

I’m not able to find the error… do I have to addapt another compas_fea library file? Or how can I implement my own material in the material library of compas (local on my computer) ?

Thank you for your support,

Hi there, you are on the right track, it seems like your new class is being imported fine, the only thing missing is you have to tell compas_fea what to do with it, and this involves editing a file to tell it what to write when it sees this new model.

When the Python file runs, at some point (for example with tthe .analyse_and_extract() method, it will write the .inp file, if you open this up now you will find that the *MATERIAL part is likely empty, due to what I explained above, therefore the analysis will fail as it doesnt have material information.

The file you need to edit for recognising and writing materials is compas_fea.fea.materials. In here is a method called write_materials(), which is where your SolidwoodC24 material info would get written. Under the Abaqus heading (elif == 'abaqus') you will see checks for the material type mtype, where mtype is grabbed from the object’s __name__, that is your SolidwoodC24.__name__ which you have already set from your code snippet.

It is then up to you to decide what to write, either you can use some of the if statements or code already in that Abaqus subsection (this is preferred), or you can (as an easy first step) branch off with your own if statement and write specifically your SolidwoodC24 model. Once you have paired your model with the file writing, and it is in the correct Abaqus .inp format, there shouldn’t be any other further changes needed, and the code should work fine.

Keep me posted.


Hi there, I’ve already edited the file you’ve refered to (compas_fea.fea.materials)

The concerning code lines are the ones below:
File: compas_fea.fea.materials (just a section of the entire file…)

        # Abaqus
        # ------------------------------------------------------------------------------------------------------

        elif == 'abaqus':

            self.write_line('*MATERIAL, NAME={0}'.format(key))

            # Elastic
            # -------

            if mtype in ['ElasticIsotropic', 'ElasticPlastic', 'Steel', 'Concrete', 'Stiff',
                         'ConcreteSmearedCrack', 'ConcreteDamagedPlasticity']:

                self.write_line('{0}, {1}'.format(E['E'], v['v']))

                if not compression:
                    self.write_line('*NO COMPRESSION')

                if not tension:
                    self.write_line('*NO TENSION')

            # Orthotropic (Type: Engineering Constants in Abaqus)
            # -------
            if mtype in ['SolidwoodC24', 'ElasticOrthotropic']

                self.write_line('*ELASTIC, TYPE=ENGINEERING CONSTANTS')
                self.write_line('{0}, {1}'.format(E['Ex','Ey','Ez'], v['vxy','vzx','vyz'], G['Gxy','Gzx']))    #only 8 field variables per line (According to the Abaqus Manual)
                self.write_line('{0}, {1}'.format(G['Gxy']))

                if not compression:
                    self.write_line('*NO COMPRESSION')

                if not tension:
                    self.write_line('*NO TENSION')

            # Compression
            # -----------

I have tried to write the code according essential Abaqus Syntax for an orthotropic elastic material (

But I got a new error message in the RhinoPython Editor command line:

And I wonder what the meaning of this message could be… :thinking:

Thank you for your support,

This looks like an error in your use of .format(), check the Python docs and online on its use, because the following will not work:

'{0}, {1}'.format(E['Ex','Ey','Ez'], v['vxy','vzx','vyz'], G['Gxy','Gzx']

as '{0}, {1}' implies two entries, but you seem to want to use 8 (Abaqus does indeed limite to 8 per line I think), and E['Ex','Ey','Ez'] looks like you are trying to access three entries in a dictionary at once, remember one key per one item (E['Ex'], E['Ey'], E['Ez']).

Thank you for your response.
I think my material works now, but the analyse has never completed successfully, when I let run the example (simple_beam).

Below you can see an extract from the created simple_beam.inp file… (Material Input):
(looks good to me)

			** Materials
			** solidwoodC24
			*MATERIAL, NAME=solidwoodC24

Error Message in the Rhino Python Editor looks as follows:

And the Abaqus CAE error looks like this:

I think that there is a problem with the ‘step_load’… It is a little confusing for me, because If I’m executing the same example with ElasticIsotropic Material (or any of the ones you and your team implemented), everything works fine.

Do you have an idea where the error comes from?

Thank you for your help :smiley:

Because the Abaqus analysis did not complete, there is nothing for compas_fea to plot, that is why the plot_data function cannot find the frame index.

To see what was wrong in the Abaqus analysis, run the .inp file in Abaqus CAE, turn the job monitor on, and it will tell you what went wrong (you are looking for the warnings, although any error information is also useful). It might be the new material, or might be something else.

Post what it says here and we can see.

1 Like

Analysis completed! :smiley::smiley::smiley:

Through the job monitor I was able to see, that my poisson ratios have been to hight.
So I’ve changed the values from 0.3 to 0.1 for all of them and it’s working now.

Great, nice to hear you got it working.

If you think at a later time that your models are well developed enough for others to use, you can consider a pull request to get them merged into compas_fea. You can find instructions on how to do pull requests on GitHub.

Have fun.