FEM: ccx writer: explicit format diggits of material values for passing unit tests

This commit is contained in:
Bernd Hahnebach 2016-08-03 13:08:30 +02:00 committed by wmayer
parent f0bbbc1cef
commit 02b84bd2e1
4 changed files with 20 additions and 20 deletions

View File

@ -278,7 +278,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
density_in_tonne_per_mm3 = 1 density_in_tonne_per_mm3 = 1
try: try:
YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus']) YM = FreeCAD.Units.Quantity(mat_obj.Material['YoungsModulus'])
YM_in_MPa = YM.getValueAs('MPa') YM_in_MPa = float(YM.getValueAs('MPa'))
except: except:
FreeCAD.Console.PrintError("No YoungsModulus defined for material: default used\n") FreeCAD.Console.PrintError("No YoungsModulus defined for material: default used\n")
try: try:
@ -287,17 +287,17 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
FreeCAD.Console.PrintError("No PoissonRatio defined for material: default used\n") FreeCAD.Console.PrintError("No PoissonRatio defined for material: default used\n")
try: try:
TC = FreeCAD.Units.Quantity(mat_obj.Material['ThermalConductivity']) TC = FreeCAD.Units.Quantity(mat_obj.Material['ThermalConductivity'])
TC_in_WmK = TC.getValueAs('W/m/K') # SvdW: Add factor to force units to results' base units of t/mm/s/K - W/m/K results in no factor needed TC_in_WmK = float(TC.getValueAs('W/m/K')) # SvdW: Add factor to force units to results' base units of t/mm/s/K - W/m/K results in no factor needed
except: except:
FreeCAD.Console.PrintError("No ThermalConductivity defined for material: default used\n") FreeCAD.Console.PrintError("No ThermalConductivity defined for material: default used\n")
try: try:
TEC = FreeCAD.Units.Quantity(mat_obj.Material['ThermalExpansionCoefficient']) TEC = FreeCAD.Units.Quantity(mat_obj.Material['ThermalExpansionCoefficient'])
TEC_in_mmK = TEC.getValueAs('mm/mm/K') TEC_in_mmK = float(TEC.getValueAs('mm/mm/K'))
except: except:
FreeCAD.Console.PrintError("No ThermalExpansionCoefficient defined for material: default used\n") FreeCAD.Console.PrintError("No ThermalExpansionCoefficient defined for material: default used\n")
try: try:
SH = FreeCAD.Units.Quantity(mat_obj.Material['SpecificHeat']) SH = FreeCAD.Units.Quantity(mat_obj.Material['SpecificHeat'])
SH_in_JkgK = SH.getValueAs('J/kg/K') * 1e+06 # SvdW: Add factor to force units to results' base units of t/mm/s/K SH_in_JkgK = float(SH.getValueAs('J/kg/K')) * 1e+06 # SvdW: Add factor to force units to results' base units of t/mm/s/K
except: except:
FreeCAD.Console.PrintError("No SpecificHeat defined for material: default used\n") FreeCAD.Console.PrintError("No SpecificHeat defined for material: default used\n")
mat_info_name = mat_obj.Material['Name'] mat_info_name = mat_obj.Material['Name']
@ -306,7 +306,7 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('**FreeCAD material name: ' + mat_info_name + '\n') f.write('**FreeCAD material name: ' + mat_info_name + '\n')
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:.0f}, {1:.3f}\n'.format(YM_in_MPa, PR))
try: try:
density = FreeCAD.Units.Quantity(mat_obj.Material['Density']) density = FreeCAD.Units.Quantity(mat_obj.Material['Density'])
density_in_tonne_per_mm3 = float(density.getValueAs('t/mm^3')) density_in_tonne_per_mm3 = float(density.getValueAs('t/mm^3'))
@ -315,11 +315,11 @@ class FemInputWriterCcx(FemInputWriter.FemInputWriter):
f.write('*DENSITY \n') f.write('*DENSITY \n')
f.write('{0:.3e}, \n'.format(density_in_tonne_per_mm3)) f.write('{0:.3e}, \n'.format(density_in_tonne_per_mm3))
f.write('*CONDUCTIVITY \n') f.write('*CONDUCTIVITY \n')
f.write('{}, \n'.format(TC_in_WmK)) f.write('{0:.3f}, \n'.format(TC_in_WmK))
f.write('*EXPANSION \n') f.write('*EXPANSION \n')
f.write('{}, \n'.format(TEC_in_mmK)) f.write('{0:.3e}, \n'.format(TEC_in_mmK))
f.write('*SPECIFIC HEAT \n') f.write('*SPECIFIC HEAT \n')
f.write('{}, \n'.format(SH_in_JkgK)) f.write('{0:.3e}, \n'.format(SH_in_JkgK))
def write_femelementsets(self, f): def write_femelementsets(self, f):
f.write('\n***********************************************************\n') f.write('\n***********************************************************\n')

View File

@ -474,15 +474,15 @@ Eall
**FreeCAD material name: Steel-Generic **FreeCAD material name: Steel-Generic
*MATERIAL, NAME=MechanicalMaterial *MATERIAL, NAME=MechanicalMaterial
*ELASTIC *ELASTIC
200000 , 0.300 200000, 0.300
*DENSITY *DENSITY
7.900e-09, 7.900e-09,
*CONDUCTIVITY *CONDUCTIVITY
1, 1.000,
*EXPANSION *EXPANSION
1, 1.000e+00,
*SPECIFIC HEAT *SPECIFIC HEAT
1, 1.000e+00,
*********************************************************** ***********************************************************
** Sections ** Sections

View File

@ -474,15 +474,15 @@ Eall
**FreeCAD material name: Steel-Generic **FreeCAD material name: Steel-Generic
*MATERIAL, NAME=MechanicalMaterial *MATERIAL, NAME=MechanicalMaterial
*ELASTIC *ELASTIC
200000 , 0.300 200000, 0.300
*DENSITY *DENSITY
7.900e-09, 7.900e-09,
*CONDUCTIVITY *CONDUCTIVITY
1, 1.000,
*EXPANSION *EXPANSION
1, 1.000e+00,
*SPECIFIC HEAT *SPECIFIC HEAT
1, 1.000e+00,
*********************************************************** ***********************************************************
** Sections ** Sections

View File

@ -104,15 +104,15 @@ Eall
**FreeCAD material name: Steel-Generic **FreeCAD material name: Steel-Generic
*MATERIAL, NAME=MechanicalMaterial *MATERIAL, NAME=MechanicalMaterial
*ELASTIC *ELASTIC
200000 , 0.300 200000, 0.300
*DENSITY *DENSITY
7.900e-09, 7.900e-09,
*CONDUCTIVITY *CONDUCTIVITY
43.27 , 43.270,
*EXPANSION *EXPANSION
1.2e-05 , 1.200e-05,
*SPECIFIC HEAT *SPECIFIC HEAT
5e+08 , 5.000e+08,
*********************************************************** ***********************************************************
** Initial temperature constraint ** Initial temperature constraint