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('** written by {} function\n'.format(sys._getframe().f_code.co_name))
|
||||
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']
|
||||
mat_obj = femobj['Object']
|
||||
# get material properties
|
||||
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
|
||||
YM_in_MPa = YM.getValueAs('MPa')
|
||||
PR = float(mat_obj.Material['PoissonRatio'])
|
||||
# get material properties - Currently in SI units: M/kg/s/Kelvin
|
||||
YM_in_MPa = 1
|
||||
PR = 1
|
||||
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_name = mat_obj.Name
|
||||
# write material properties
|
||||
|
@ -168,10 +178,13 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
|
|||
f.write('*MATERIAL, NAME=' + mat_name + '\n')
|
||||
f.write('*ELASTIC \n')
|
||||
f.write('{0}, {1:.3f}\n'.format(YM_in_MPa, PR))
|
||||
density = FreeCAD.Units.Quantity(mat_obj.Material['Density'])
|
||||
density_in_tone_per_mm3 = float(density.getValueAs('t/mm^3'))
|
||||
try:
|
||||
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('{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):
|
||||
f.write('\n***********************************************************\n')
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Properties</string>
|
||||
<string>Material Properties</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
|
@ -122,6 +122,9 @@
|
|||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>200 GPa</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
|
@ -176,7 +179,7 @@
|
|||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
<double>0.300000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -202,7 +205,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>8000 kg/m^3</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -214,7 +217,7 @@
|
|||
<double>2000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">kg/mm^3</string>
|
||||
<string notr="true">kg/m^3</string>
|
||||
</property>
|
||||
<property name="decimals" stdset="0">
|
||||
<number>3</number>
|
||||
|
|
|
@ -122,7 +122,7 @@ class _TaskPanelMechanicalMaterial:
|
|||
def ym_changed(self, value):
|
||||
import Units
|
||||
# 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
|
||||
if value:
|
||||
if not (1 - variation < float(old_ym) / value < 1 + variation):
|
||||
|
@ -134,15 +134,14 @@ class _TaskPanelMechanicalMaterial:
|
|||
def density_changed(self, value):
|
||||
import Units
|
||||
# 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
|
||||
if value:
|
||||
if not (1 - variation < float(old_density) / value < 1 + variation):
|
||||
# density has changed
|
||||
material = self.material
|
||||
value_in_kg_per_m3 = value * 1e9
|
||||
material['Density'] = unicode(value_in_kg_per_m3) + " kg/m^3"
|
||||
# material['Density'] = unicode(value) + " kg/mm^3"
|
||||
material['Density'] = unicode(value_in_kg_per_m3) + " kg/m^3" # SvdW:Keep density in SI units for easier readability
|
||||
self.material = material
|
||||
|
||||
def pr_changed(self, value):
|
||||
|
|
Loading…
Reference in New Issue
Block a user