Skip to content

Commit

Permalink
FEM, Material: Add DENSITY to inp files and basic material files
Browse files Browse the repository at this point in the history
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and yorikvanhavre committed Jul 31, 2015
1 parent b85c443 commit d380187
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 9 deletions.
16 changes: 16 additions & 0 deletions src/Mod/Fem/MechanicalMaterial.py
Expand Up @@ -133,6 +133,7 @@ def __init__(self, obj):
QtCore.QObject.connect(self.form.cb_materials, QtCore.SIGNAL("activated(int)"), self.choose_material)
QtCore.QObject.connect(self.form.input_fd_young_modulus, QtCore.SIGNAL("valueChanged(double)"), self.ym_changed)
QtCore.QObject.connect(self.form.spinBox_poisson_ratio, QtCore.SIGNAL("valueChanged(double)"), self.pr_changed)
QtCore.QObject.connect(self.form.input_fd_density, QtCore.SIGNAL("valueChanged(double)"), self.density_changed)
self.previous_material = self.obj.Material
self.import_materials()
previous_mat_path = self.get_material_path(self.previous_material)
Expand Down Expand Up @@ -171,6 +172,14 @@ def ym_changed(self, value):
material['YoungsModulus'] = unicode(value) + " kPa"
self.obj.Material = material

def density_changed(self, value):
import Units
old_density = Units.Quantity(self.obj.Material['Density'])
if old_density != value:
material = self.obj.Material
material['Density'] = unicode(value) + " kg/mm^3"
self.obj.Material = material

def pr_changed(self, value):
import Units
old_pr = Units.Quantity(self.obj.Material['PoissonRatio'])
Expand Down Expand Up @@ -212,6 +221,8 @@ def print_mat_data(self, matmap):
print ' YM = ', matmap['YoungsModulus']
if 'PoissonRatio' in matmap:
print ' PR = ', matmap['PoissonRatio']
if 'Density' in matmap:
print ' RO = ', matmap['Density']

def set_mat_params_in_combo_box(self, matmap):
if 'YoungsModulus' in matmap:
Expand All @@ -221,6 +232,11 @@ def set_mat_params_in_combo_box(self, matmap):
self.form.input_fd_young_modulus.setText("{} {}".format(ym_with_new_unit, ym_new_unit))
if 'PoissonRatio' in matmap:
self.form.spinBox_poisson_ratio.setValue(float(matmap['PoissonRatio']))
if 'Density' in matmap:
density_new_unit = "kg/m^3"
density = FreeCAD.Units.Quantity(matmap['Density'])
density_with_new_unit = density.getValueAs(density_new_unit)
self.form.input_fd_density.setText("{} {}".format(density_with_new_unit, density_new_unit))

def add_transient_material(self, material):
material_name = self.get_material_name(material)
Expand Down
63 changes: 55 additions & 8 deletions src/Mod/Fem/MechanicalMaterial.ui
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>188</width>
<height>124</height>
<width>253</width>
<height>275</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -36,6 +36,9 @@
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
Expand All @@ -60,18 +63,18 @@
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">Pa</string>
</property>
<property name="decimals" stdset="0">
<number>3</number>
</property>
<property name="maximum" stdset="0">
<double>2000000000.000000000</double>
</property>
<property name="singleStep" stdset="0">
<double>2.000000000000000</double>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
Expand Down Expand Up @@ -115,6 +118,50 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Density</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::InputField" name="input_fd_density">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>0 kg/m^3</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="singleStep">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>2000000000.000000000000000</double>
</property>
<property name="unit" stdset="0">
<string notr="true">kg/m^3</string>
</property>
<property name="decimals" stdset="0">
<number>3</number>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
6 changes: 5 additions & 1 deletion src/Mod/Fem/ccxInpWriter.py
Expand Up @@ -122,8 +122,12 @@ def write_materials(self, f):
# write material properties
f.write('*MATERIAL, NAME=' + mat_name + '\n')
f.write('*ELASTIC \n')
f.write('{}, '.format(YM_in_MPa))
f.write('{}, \n'.format(YM_in_MPa))
f.write('{0:.3f}\n'.format(PR))
density = FreeCAD.Units.Quantity(mat_obj.Material['Density'])
density_in_kg_per_mm3 = density.getValueAs('t/mm^3')
f.write('*DENSITY \n')
f.write('{}, \n'.format(density_in_kg_per_mm3))
# write element properties
if len(self.material_objects) == 1:
f.write('*SOLID SECTION, ELSET=' + mat_obj_name + ', MATERIAL=' + mat_name + '\n')
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/ABS.FCMat
Expand Up @@ -24,6 +24,7 @@ SpecificPrice= 3
YoungsModulus=2320 MPa
; http://en.wikipedia.org/wiki/Ultimate_tensile_strength in
UltimateTensileStrength= 38 MPa
Density=1070 kg/m^3

[FEM]
PoissonRatio = 0.35
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/CalculiX.FCMat
Expand Up @@ -9,6 +9,7 @@ Father=Metal
[Mechanical]
; youngs modulus (or E-Module)
YoungsModulus=210000 MPa
Density=1000 kg/m^3

[FEM]
PoissonRatio = 0.3
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/Concrete-Generic.FCMat
Expand Up @@ -19,6 +19,7 @@ CompressiveStrength=25 MPa
YoungsModulus=32000 MPa
Elasticity=
FractureToughness=
Density=2000 kg/m^3

[FEM]
PoissonRatio=0.17
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/None.FCMat
Expand Up @@ -22,6 +22,7 @@ SpecificPrice = 0.0
YoungsModulus=0 MPa
; http://en.wikipedia.org/wiki/Ultimate_tensile_strength in
UltimateTensileStrength= 0 MPa
Density=0 kg/m^3

[FEM]
PoissonRatio = 0.0
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/PLA.FCMat
Expand Up @@ -24,6 +24,7 @@ SpecificPrice= 4
YoungsModulus=3640 MPa
; http://en.wikipedia.org/wiki/Ultimate_tensile_strength
UltimateTensileStrength= 49.6 MPa
Density=1300 kg/m^3


[FEM]
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/Steel-Generic.FCMat
Expand Up @@ -30,6 +30,7 @@ CompressiveStrength=
Elasticity=
; http://en.wikipedia.org/wiki/Fracture_toughness
FractureToughness:
Density=7900 kg/m^3

[FEM]
PoissonRatio = 0.3
1 change: 1 addition & 0 deletions src/Mod/Material/StandardMaterial/Wood-Generic.FCMat
Expand Up @@ -18,6 +18,7 @@ CompressiveStrength=
YoungsModulus=12000 MPa
Elasticity=
FractureToughness=
Density=0.7 kg/m^3

[FEM]
PoissonRatio=0.05
Expand Down

0 comments on commit d380187

Please sign in to comment.