FEM: materials: some small changes in task panel and ccx writer
This commit is contained in:
parent
eb305c142f
commit
03ca2ebe55
|
@ -155,12 +155,22 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
||||||
f.write('** Materials\n')
|
f.write('** Materials\n')
|
||||||
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||||
f.write('** Young\'s modulus unit is MPa = N/mm2\n')
|
f.write('** Young\'s modulus unit is MPa = N/mm2\n')
|
||||||
|
f.write('** Density\'s unit is t/mm^3\n')
|
||||||
for femobj in self.material_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
|
for femobj in self.material_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
|
||||||
mat_obj = femobj['Object']
|
mat_obj = femobj['Object']
|
||||||
# get material properties
|
# get material properties - Currently in SI units: M/kg/s/Kelvin
|
||||||
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
|
YM_in_MPa = 1
|
||||||
YM_in_MPa = YM.getValueAs('MPa')
|
PR = 1
|
||||||
PR = float(mat_obj.Material['PoissonRatio'])
|
density_in_tonne_per_mm3 = 1
|
||||||
|
try:
|
||||||
|
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
|
||||||
|
YM_in_MPa = YM.getValueAs('MPa')
|
||||||
|
except:
|
||||||
|
FreeCAD.Console.PrintError("No YoungsModulus defined for material: default used\n")
|
||||||
|
try:
|
||||||
|
PR = float(mat_obj.Material['PoissonRatio'])
|
||||||
|
except:
|
||||||
|
FreeCAD.Console.PrintError("No PoissonRatio defined for material: default used\n")
|
||||||
mat_info_name = mat_obj.Material['Name']
|
mat_info_name = mat_obj.Material['Name']
|
||||||
mat_name = mat_obj.Name
|
mat_name = mat_obj.Name
|
||||||
# write material properties
|
# write material properties
|
||||||
|
@ -168,10 +178,13 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
||||||
f.write('*MATERIAL, NAME=' + mat_name + '\n')
|
f.write('*MATERIAL, NAME=' + mat_name + '\n')
|
||||||
f.write('*ELASTIC \n')
|
f.write('*ELASTIC \n')
|
||||||
f.write('{0}, {1:.3f}\n'.format(YM_in_MPa, PR))
|
f.write('{0}, {1:.3f}\n'.format(YM_in_MPa, PR))
|
||||||
density = FreeCAD.Units.Quantity(mat_obj.Material['Density'])
|
try:
|
||||||
density_in_tone_per_mm3 = float(density.getValueAs('t/mm^3'))
|
density = FreeCAD.Units.Quantity(mat_obj.Material['Density'])
|
||||||
|
density_in_tonne_per_mm3 = float(density.getValueAs('t/mm^3'))
|
||||||
|
except:
|
||||||
|
FreeCAD.Console.PrintError("No Density defined for material: default used\n")
|
||||||
f.write('*DENSITY \n')
|
f.write('*DENSITY \n')
|
||||||
f.write('{0:.3e}, \n'.format(density_in_tone_per_mm3))
|
f.write('{0:.3e}, \n'.format(density_in_tonne_per_mm3))
|
||||||
|
|
||||||
def write_femelementsets(self, f):
|
def write_femelementsets(self, f):
|
||||||
f.write('\n***********************************************************\n')
|
f.write('\n***********************************************************\n')
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Properties</string>
|
<string>Material Properties</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
|
@ -122,6 +122,9 @@
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>200 GPa</string>
|
||||||
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
@ -176,7 +179,7 @@
|
||||||
<double>0.100000000000000</double>
|
<double>0.100000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<double>0.000000000000000</double>
|
<double>0.300000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -202,7 +205,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>8000 kg/m^3</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -214,7 +217,7 @@
|
||||||
<double>2000000000.000000000000000</double>
|
<double>2000000000.000000000000000</double>
|
||||||
</property>
|
</property>
|
||||||
<property name="unit" stdset="0">
|
<property name="unit" stdset="0">
|
||||||
<string notr="true">kg/mm^3</string>
|
<string notr="true">kg/m^3</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="decimals" stdset="0">
|
<property name="decimals" stdset="0">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
|
|
|
@ -122,7 +122,7 @@ class _TaskPanelMechanicalMaterial:
|
||||||
def ym_changed(self, value):
|
def ym_changed(self, value):
|
||||||
import Units
|
import Units
|
||||||
# FreeCADs standard unit for stress is kPa
|
# FreeCADs standard unit for stress is kPa
|
||||||
old_ym = Units.Quantity(self.material['YoungsModulus'])
|
old_ym = Units.Quantity(self.material['YoungsModulus']).getValueAs("kPa")
|
||||||
variation = 0.001
|
variation = 0.001
|
||||||
if value:
|
if value:
|
||||||
if not (1 - variation < float(old_ym) / value < 1 + variation):
|
if not (1 - variation < float(old_ym) / value < 1 + variation):
|
||||||
|
@ -134,15 +134,14 @@ class _TaskPanelMechanicalMaterial:
|
||||||
def density_changed(self, value):
|
def density_changed(self, value):
|
||||||
import Units
|
import Units
|
||||||
# FreeCADs standard unit for density is kg/mm^3
|
# FreeCADs standard unit for density is kg/mm^3
|
||||||
old_density = Units.Quantity(self.material['Density'])
|
old_density = Units.Quantity(self.material['Density']).getValueAs("kg/m^3")
|
||||||
variation = 0.001
|
variation = 0.001
|
||||||
if value:
|
if value:
|
||||||
if not (1 - variation < float(old_density) / value < 1 + variation):
|
if not (1 - variation < float(old_density) / value < 1 + variation):
|
||||||
# density has changed
|
# density has changed
|
||||||
material = self.material
|
material = self.material
|
||||||
value_in_kg_per_m3 = value * 1e9
|
value_in_kg_per_m3 = value * 1e9
|
||||||
material['Density'] = unicode(value_in_kg_per_m3) + " kg/m^3"
|
material['Density'] = unicode(value_in_kg_per_m3) + " kg/m^3" # SvdW:Keep density in SI units for easier readability
|
||||||
# material['Density'] = unicode(value) + " kg/mm^3"
|
|
||||||
self.material = material
|
self.material = material
|
||||||
|
|
||||||
def pr_changed(self, value):
|
def pr_changed(self, value):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user