Commit 4926b9a7 authored by John Tourtellott's avatar John Tourtellott

Update initial conditions and add smoothing radius

* Add/fix python code for initial temp as polynomial f(x,y,z)
* Add smoothing-radius item to phase-transition attribute
parent c71ba603
......@@ -598,33 +598,6 @@
<Value>linear</Value>
</DiscreteInfo>
</String>
<Group Name="tabular-data" Label="Tabular Data" Extensible="true" NumberOfRequiredGroups="1">
<ItemDefinitions>
<Double Name="X" Label="X:" NumberOfRequiredValues="1">
<Categories>
<Cat>Heat Transfer</Cat>
</Categories>
<DefaultValue>0</DefaultValue>
</Double>
<Double Name="Y" Label="Y:" NumberOfRequiredValues="1">
<Categories>
<Cat>Heat Transfer</Cat>
</Categories>
<DefaultValue>0</DefaultValue>
</Double>
<Double Name="Z" Label="Z:" NumberOfRequiredValues="1">
<Categories>
<Cat>Heat Transfer</Cat>
</Categories>
<DefaultValue>0</DefaultValue>
</Double>
<Double Name="Value" Label="Temperature" NumberOfRequiredValues="1">
<Categories>
<Cat>Heat Transfer</Cat>
</Categories>
</Double>
</ItemDefinitions>
</Group>
<Double Name="center" Label="Center Coordinates" NumberOfRequiredValues="3">
<Categories>
<Cat>Heat Transfer</Cat>
......@@ -652,7 +625,7 @@
</ItemDefinitions>
</Group>
</ChildrenDefinitions>
<DiscreteInfo>
<DiscreteInfo DefaultIndex="0">
<Structure>
<Value Enum="Polynomial">polynomial</Value>
<Items>
......@@ -660,14 +633,6 @@
<Item>polynomial-terms</Item>
</Items>
</Structure>
<Structure>
<Value Enum="Tabular">tabular</Value>
<Items>
<Item>interpolation</Item>
<Item>extrapolation</Item>
<Item>tabular-data</Item>
</Items>
</Structure>
</DiscreteInfo>
</String>
</ItemDefinitions>
......
......@@ -152,7 +152,7 @@ density from the reference density</BriefDescription>
<ItemDefinitions>
<Component Name="lower" Label="Low-Temperature phase" NumberOfRequiredValues="1">
<Accepts>
<Resource Name="smtk::attribute::Resource" Filter="attribute[type='phase']"/>
<Resource Name="smtk::attribute::Resource" Filter="attribute[type='phase.material']"/>
</Accepts>
<Categories>
<Cat>Fluid Flow</Cat>
......@@ -190,6 +190,18 @@ density from the reference density</BriefDescription>
</Categories>
<DefaultValue>100.0</DefaultValue>
</Double>
<Double Name="smoothing-radius" Label="Smoothing Radius" NumberOfRequiredValues="1" Optional="true" IsEnabledByDefault="false" Version="0">
<Categories>
<Cat>Fluid Flow</Cat>
<Cat>Heat Transfer</Cat>
<Cat>Induction Heating</Cat>
<Cat>Solid Mechanics</Cat>
</Categories>
<BriefDescription>The transition smoothing function. Default 0.25 times delta T.</BriefDescription>
<RangeInfo>
<Min Inclusive="true">0.0</Min>
</RangeInfo>
</Double>
<Component Name="upper" Label="High-Temperature Phase" NumberOfRequiredValues="1">
<Categories>
<Cat>Fluid Flow</Cat>
......@@ -198,7 +210,7 @@ density from the reference density</BriefDescription>
<Cat>Solid Mechanics</Cat>
</Categories>
<Accepts>
<Resource Name="smtk::attribute::Resource" Filter="attribute[type='phase']"/>
<Resource Name="smtk::attribute::Resource" Filter="attribute[type='phase.material']"/>
</Accepts>
</Component>
</ItemDefinitions>
......
......@@ -118,19 +118,6 @@ SMTK_AttributeResource(Version="3")
ChildrenDefinitions
//- Tabular items
+tabCommon("Heat Transfer")
Group(Name="tabular-data" Label="Tabular Data" Extensible="true" NumberOfRequiredGroups="1")
ItemDefinitions
Double(Name="X" Label="X:" NumberOfRequiredValues="1")
Categories #[Cat Heat Transfer]
DefaultValue 0
Double(Name="Y" Label="Y:" NumberOfRequiredValues="1")
Categories #[Cat Heat Transfer]
DefaultValue 0
Double(Name="Z" Label="Z:" NumberOfRequiredValues="1")
Categories #[Cat Heat Transfer]
DefaultValue 0
Double(Name="Value" Label="Temperature" NumberOfRequiredValues="1")
Categories #[Cat Heat Transfer]
Double(Name="center" Label="Center Coordinates" NumberOfRequiredValues="3")
Categories #[Cat Heat Transfer]
DefaultValue 0
......@@ -145,7 +132,13 @@ SMTK_AttributeResource(Version="3")
Label Y
Label Z
DefaultValue 0
+fnDiscreteInfo
//- +fnDiscreteInfo
DiscreteInfo(DefaultIndex="0")
Structure
Value(Enum="Polynomial") polynomial
Items
Item center
Item polynomial-terms
//- Views
//- View(Title="Functions" Type="Attribute" TopLevel="True")
......
......@@ -104,7 +104,7 @@ SMTK_AttributeResource(Version="3")
ItemDefinitions
Component(Name="lower" Label="Low-Temperature phase" NumberOfRequiredValues="1")
Accepts
Resource(Name="smtk::attribute::Resource" Filter="attribute[type='phase']")
Resource(Name="smtk::attribute::Resource" Filter="attribute[type='phase.material']")
+categories-all
Double(Name="latent-heat" Label="Latent Heat (Lf)")
+categories-all
......@@ -116,9 +116,14 @@ SMTK_AttributeResource(Version="3")
Double(Name="upper-transition-temperature" Label="High Transition Temperature (Tl)")
+categories-all
DefaultValue 100.0
Double(Name="smoothing-radius" Label="Smoothing Radius" NumberOfRequiredValues=1 Optional="true" IsEnabledByDefault="false" Version="0")
+categories-all
BriefDescription The transition smoothing function. Default 0.25 times delta T.
RangeInfo
Min(Inclusive="true") 0.0
Component(Name="upper" Label="High-Temperature Phase" NumberOfRequiredValues="1")
+categories-all
Accepts
Resource(Name="smtk::attribute::Resource" Filter="attribute[type='phase']")
Resource(Name="smtk::attribute::Resource" Filter="attribute[type='phase.material']")
= "\n"
......@@ -666,22 +666,32 @@ class Writer:
if function_type == 'polynomial':
group_item = att.itemAtPath('type/polynomial-terms')
num_groups = group_item.numberOfGroups()
coef_table = dict() # <exponent, coefficient>
for i in range(group_item.numberOfGroups()):
x = group_item.item(i, 0).value()
y = group_item.item(i, 1).value()
coef_table[y] = x
if num_groups < 1:
print('Warning: function {} contents are empty -- skipping'.format(att.name()))
continue
# Get number of independent vars
exp_item0 = group_item.item(0, 1)
num_vars = exp_item0.numberOfValues()
coef_list = [0.0] * num_groups
# Create 2D list for exponentials [group][variable]
exp_lists = [ [0 for x in range(num_vars)] for y in range(num_groups) ]
# Get max coefficient
ytop = max(coef_table.keys()) + 1
exp_list = range(ytop)
for i in range(num_groups):
coef_item = group_item.item(i, 0)
coef_list[i] = coef_item.value()
exp_item = group_item.item(i, 1)
for j in range(num_vars):
exp_lists[i][j] = exp_item.value(j)
coef_list = [0] * ytop
for i in exp_list:
coef_list[i] = coef_table.get(i, 0)
CardFormat.write_value(self.out, 'poly_coefficients', coef_list)
CardFormat.write_value(self.out, 'poly_exponents(1,:)', exp_list)
for k in range(num_groups):
keyword = 'poly_exponents(:, {})'.format(k+1)
CardFormat.write_value(self.out, keyword, exp_lists[k])
# Finish with the center value
CardFormat('poly_refvars', item_path='type/center').write(self.out, att)
......@@ -924,7 +934,8 @@ class Writer:
lower_temps = list()
upper_temps = list()
latent_heats = list()
numbers = list()
smoothing_radius = None
numbers = list() # material numbers
trans_att = att
lower_att = trans_att.findComponent('lower').value()
......@@ -946,6 +957,14 @@ class Writer:
latent_heat = trans_att.findDouble('latent-heat')
latent_heats.append(latent_heat.value())
# Smoothing radius currently part of transition, but only a single value
# applies to the material system. This code takes the smoothing radius
# from the *first* transition that has its item enabled.
if smoothing_radius is None:
smoothing_radius_item = trans_att.findDouble('smoothing-radius')
if smoothing_radius_item and smoothing_radius_item.isEnabled():
smoothing_radius = smoothing_radius_item.value()
# Get next transition
trans_att = lower_transition_dict.get(upper_att.id())
......@@ -971,6 +990,8 @@ class Writer:
CardFormat.write_value(self.out, 'transition_temps_low', lower_temps)
CardFormat.write_value(self.out, 'transition_temps_high', upper_temps)
CardFormat.write_value(self.out, 'latent_heat', latent_heats)
if smoothing_radius is not None:
CardFormat.write_value(self.out, 'smoothing_radius', smoothing_radius)
self._finish_namelist()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment