3
« on: September 27, 2021, 05:17:00 PM »
Dear Tetsuo,
there exists a command that let's you change the temperature, it's syntax is fairly simple:
SetTemperature_args = {
'Temperature' : (293.15, 'K'),
}
gd.runCmd("GeoDict:SetTemperature", SetTemperature_args, "2021")
It changes the temperate in the current constituent material settings. When using this command in a macro, you have to be aware that most commands (e.g. in FlowDict) contain their own set of material parameters. Therefore, after changing the temperature, it will be changed in the active settings, but not in the recorded command. So you have to take the active settings with
gd.getConstituentMaterials( "2021" )
and insert these constituent materials in the parameter list of the FlowDict command, before calling the flow solver.
The following macro gives an example how this can be done:
Header = {
'Release' : '2021',
}
Description = '''
Compute flow for different temperatures.
'''
def createBaseGeo():
Create_args_1 = {
'Domain' : {
'PeriodicX' : False,
'PeriodicY' : False,
'PeriodicZ' : False,
'OriginX' : (0, 'm'),
'OriginY' : (0, 'm'),
'OriginZ' : (0, 'm'),
'VoxelLength' : (1e-06, 'm'),
'DomainMode' : 'VoxelNumber', # Possible values: VoxelNumber, Length, VoxelNumberAndLength
'NX' : 100,
'NY' : 100,
'NZ' : 100,
'Material' : {
'Name' : 'Air',
'Type' : 'Fluid', # Possible values: Fluid, Solid, Porous, Undefined
'Information' : '',
},
'OverlapMode' : 'GivenMaterial', # Possible values: OverlapMaterial, NewMaterial, OldMaterial, GivenMaterial
'OverlapMaterialID' : 3,
'NumOverlapRules' : 2,
'OverlapRule1' : {
'MaterialID1' : 1,
'MaterialID2' : 1,
'OverlapMaterialID' : 1,
},
'OverlapRule2' : {
'MaterialID1' : 2,
'MaterialID2' : 2,
'OverlapMaterialID' : 2,
},
'HollowMaterialID' : 0,
'PostProcessing' : {
'ResolveOverlap' : False,
'MarkContactVoxels' : False,
'ContactMaterialID' : 3,
},
},
'MaximalTime' : (24, 'h'),
'OverlapMode' : 'AllowOverlap', # Possible values: AllowOverlap, RemoveOverlap, ForceConnection, IsolationDistance, ProhibitWithExisting, ProhibitOverlap, MatchSVFDistribution
'StoppingCriterion' : 'SolidVolumePercentage',# Possible values: SolidVolumePercentage, NumberOfObjects, Grammage, Density, WeightPercentage, FillToRim, SVP, Number
'NumberOfObjects' : 100,
'SolidVolumePercentage' : (10, '%'),
'Grammage' : (10, 'g/m^2'),
'Density' : (0, 'g/cm^3'),
'WeightPercentage' : (0, '%'),
'SaveGadStep' : 10,
'RecordIntermediateResult' : False,
'InExisting' : False,
'KeepStructure' : False,
'MatchSVFDistribution' : {
'ErrorBound' : 0.001,
'CoarseningFactor' : 10,
'MatchMode' : 'Gauss', # Possible values: Gauss, Gradient
'RelativeDensity' : True,
'DensityFunction' : {
'XValues' : [0, 0.5, 1],
'YValues' : [1, 0.1, 1],
},
'CorrelationLengthX' : (2e-05, 'm'),
'CorrelationLengthY' : (2e-05, 'm'),
'CorrelationLengthZ' : (1e-05, 'm'),
'StandardDeviation' : 0.5,
},
'RemoveOverlap' : {
'Iterations' : 1000,
'OverlapSVP' : (0, '%'),
'SVPUnchanged' : 20,
'AllowShift' : True,
'AllowRotation' : True,
'AllowDeformation' : True,
'NumberOfShifts' : 10,
'ShiftDistance' : (2, 'Voxel'),
'NumberOfRotations' : 20,
'MaximalAngle' : 60,
'DistanceMode' : 'Touch', # Possible values: Touch, Overlap, Isolation, AvoidContact
'IsolationDistance' : (0, 'm'),
'MaximalOverlap' : (0, 'm'),
},
'IsolationDistance' : (0, 'm'),
'PercentageType' : 0,
'RandomSeed' : 47,
'ResultFileName' : 'FiberGeo.gdr',
'MatrixDensity' : (0, 'g/cm^3'),
'MaterialMode' : 'Material', # Possible values: Material, MaterialID
'MaterialIDMode' : 'MaterialIDPerObjectType',# Possible values: MaterialIDPerObjectType, MaterialIDPerMaterial
'OverlapMaterial' : {
'Name' : 'Glass',
'Type' : 'Solid', # Possible values: Fluid, Solid, Porous, Undefined
'Information' : 'Overlap',
},
'ContactMaterial' : {
'Name' : 'Glass',
'Type' : 'Solid', # Possible values: Fluid, Solid, Porous, Undefined
'Information' : 'Contact',
},
'NumberOfGenerators' : 2,
'Generator1' : {
'Material' : {
'Name' : 'Glass',
'Type' : 'Solid', # Possible values: Fluid, Solid, Porous, Undefined
'Information' : 'Fiber',
},
'Probability' : 0.5,
'SpecificWeight' : (2.58, 'g/cm^3'),
'Type' : 'InfiniteCircularFiberGenerator',
'UseDTex' : False,
'DiameterDistribution' : {
'Type' : 'Constant', # Possible values: Constant, UniformlyInInterval, Gaussian, Table, LogNormal
'Value' : 1e-05,
},
'OrientationDistribution' : {
'Type' : 'AnisotropicDirection',# Possible values: Isotropic, AnisotropicDirection, AnisotropicOrientation, GivenDirection, InXYPlane, AngleAroundDirection, UNDEF
'DirectionMode' : 'AnisotropyParameter',# Possible values: AnisotropyParameter, DirectionTensor
'Anisotropy1' : 7,
'Anisotropy2' : 1,
'Phi' : 0,
'Theta' : 0,
'Psi' : 0,
},
},
'Generator2' : {
'Material' : {
'Name' : 'Glass',
'Type' : 'Solid', # Possible values: Fluid, Solid, Porous, Undefined
'Information' : 'Fiber',
},
'Probability' : 0.5,
'SpecificWeight' : (2.58, 'g/cm^3'),
'Type' : 'InfiniteCircularFiberGenerator',
'UseDTex' : False,
'DiameterDistribution' : {
'Type' : 'Constant', # Possible values: Constant, UniformlyInInterval, Gaussian, Table, LogNormal
'Value' : 6e-06,
},
'OrientationDistribution' : {
'Type' : 'AnisotropicDirection',# Possible values: Isotropic, AnisotropicDirection, AnisotropicOrientation, GivenDirection, InXYPlane, AngleAroundDirection, UNDEF
'DirectionMode' : 'AnisotropyParameter',# Possible values: AnisotropyParameter, DirectionTensor
'Anisotropy1' : 5,
'Anisotropy2' : 1,
'Phi' : 0,
'Theta' : 0,
'Psi' : 0,
},
},
'Temperature' : (293.15, 'K'),
}
gd.runCmd("FiberGeo:Create", Create_args_1, Header['Release'])
def getConstituentMaterials(temp):
SetTemperature_args_1 = {
'Temperature' : (273.15+temp, 'K'),
}
gd.runCmd("GeoDict:SetTemperature", SetTemperature_args_1, Header['Release'])
coMatDict = gd.getConstituentMaterials( Header['Release'] )
coMatDict['ChosenFluid'] = {
'Fluid' : 'Air',
}
return coMatDict
def getStokesPara(coMatDict, temp):
SolveStokesDict = {
'ResultFileName' : 'StokesResult_T' + str(temp) + '.gdr',
'ConstituentMaterials' : {},
'SolverData' : {
'DirectionEnabledX' : 0,
'DirectionEnabledY' : 0,
'DirectionEnabledZ' : 1,
'CharLengthMode' : 'PERMEABILITY', # Possible values: PERMEABILITY, PORE_SIZE, FIBER_SIZE, USER_GIVEN
'GivenCharLength' : 1,
'PressureDifference' : (0.02, 'Pa'),
'MeanVelocity' : (0.1, 'm/s'),
'FlowRate' : (60, 'l/min'),
'FlowArea' : (100, 'cm^2'),
'ExperimentIO' : 'PressureDrop',
'AddInletOutlet' : True,
'InletLength' : 10,
'OutletLength' : 10,
'SlipLength' : 0,
'NormalBcType' : 'Periodic',
'TangentialBcYInX' : 'Periodic',
'TangentialBcZInX' : 'Periodic',
'TangentialBcXInY' : 'Periodic',
'TangentialBcZInY' : 'Periodic',
'TangentialBcXInZ' : 'Periodic',
'TangentialBcYInZ' : 'Periodic',
'Parallelization' : {
'Mode' : 'LOCAL_MAX', # Possible values: Sequential, LOCAL_THREADS, LOCAL_MPI, LOCAL_MAX, CLUSTER, Undefined
},
'DiscardTemporaryFiles' : False,
'AnalyzeGeometry' : True,
'Restart' : 0,
'RestartFileName' : '',
'RestartSaveIntervalTime' : 6,
'UseTolerance' : False,
'Tolerance' : 0.0001,
'UseErrorBound' : True,
'ErrorBound' : 0.01,
'MaxNumberOfIterations' : 100000,
'MaximalSolverRunTime' : (240, 'h'),
'UseMaxIterations' : False,
'UseMaxTime' : False,
'UseLateral' : False,
'UseMultigrid' : True,
'Optimization' : 'Speed',
'GridType' : 'LIR-Tree',
'Relaxation' : 1,
'Refinement' : 'ENABLED', # Possible values: ENABLED, DISABLED, MANUAL
'WriteCompressedFields' : True,
},
}
SolveStokesDict['ConstituentMaterials'] = coMatDict;
return SolveStokesDict
# start main
createBaseGeo()
temp = 20.0 # Celsius
gd.runCmd( "FlowDict:SolveLIRStokes", getStokesPara( getConstituentMaterials( temp ), temp ), Header['Release'] )
temp = 50.0 # Celsius
gd.runCmd( "FlowDict:SolveLIRStokes", getStokesPara( getConstituentMaterials( temp ), temp ), Header['Release'] )