Units in .inp file writer

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Units in .inp file writer

Post by PrzemoF »

That unit handling code doesn't look right [1]

Code: Select all

        for MaterialObject in self.MaterialObjects:
            # get material properties
            YM = FreeCAD.Units.Quantity(MaterialObject['Object'].Material['Mechanical_youngsmodulus'])
            if YM.Unit.Type == '':
                print 'Material "Mechanical_youngsmodulus" has no Unit, asuming kPa!' <-- assuming kPa...
                YM = FreeCAD.Units.Quantity(YM.Value, FreeCAD.Units.Unit('Pa')) <-- but setting Pa. What's the reason?
            else:
                print 'YM unit: ', YM.Unit.Type <-- this prints "YM Unit: Pressure", not very useful
            print 'YM = ', YM  <-- this prints "YM = 2e+08 kg/mm*s^2", again the units are not useful
            PR = float(MaterialObject['Object'].Material['FEM_poissonratio'])
            print 'PR = ', PR
            # write material properties
            inpfile.write('*MATERIAL, NAME=' + MaterialObject['Object'].Material['General_name'] + '\n')
            inpfile.write('*ELASTIC \n')
            inpfile.write('{0:.3f}, '.format(YM.Value * 1E-3)) <-- this conversion by 1/000 is unit independent, so if the YM unit is not kPa it will produce something else not expected MPa
            
I want to flag that for review in case I missed something.
[1] https://github.com/FreeCAD/FreeCAD_sf_m ... is.py#L498
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Units in .inp file writer

Post by bernd »

I did not change anything on that with the last commit. It's the following commit you are talking about.
https://github.com/FreeCAD/FreeCAD_sf_m ... 7db34dcd6e
(https://github.com/FreeCAD/FreeCAD_sf_m ... 400602R444)

Nothing has been changed on youngs modulus since then. That was done at a time when lot of things were messed up in FEM to get some system running. Setting unit to Pa is from years ago.
Last edited by bernd on Thu Apr 23, 2015 10:24 am, edited 1 time in total.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Units in .inp file writer

Post by PrzemoF »

OK, makes perfect sense. We'll clean it later, after splitting the .inp write code.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Units in .inp file writer

Post by bernd »

PrzemoF wrote:We'll clean it later, after splitting the .inp write code.
+1
Post Reply