Commit ec651554 authored by John Tourtellott's avatar John Tourtellott

Update T3P Power Monitor to use Analysis times as default

parent 926a57f8
......@@ -568,7 +568,7 @@ def write_loading_info(scope):
boundary_item = att.findModelEntity('SourceBoundary')
boundary_ids = utils.get_entity_ids(scope, boundary_item)
if len(boundary_ids) == 0:
raise Exception('No SourceBoundary specified for LoadingInfo %s' % att.name())
raise Exception('No SourceBoundary specified for LoadingInfo %s ' % att.name())
scope.output.write(' BoundaryID: %d\n' % boundary_ids[0])
# Finish LoadingInfo
......@@ -591,10 +591,20 @@ def write_time_stepping(scope):
scope.output.write('TimeStepping:\n')
scope.output.write('{\n')
max_time = feinfo_att.findDouble('MaxTime').value(0)
# Max time
max_time_item = feinfo_att.findDouble('MaxTime')
if not max_time_item.isSet(0):
msg = 'Cannot export because "Maximum Time" is not set in the Analysis tab '
raise Exception(msg)
max_time = max_time_item.value(0)
scope.output.write(' MaximumTime: %g\n' % max_time)
dt = feinfo_att.findDouble('DT').value(0)
# Time step
dt_item = feinfo_att.findDouble('DT')
if not dt_item.isSet(0):
msg = 'Cannot export because "Time Step" is not set in the Analysis tab '
raise Exception(msg)
dt = dt_item.value(0)
scope.output.write(' DT: %g\n' % dt)
scope.output.write('}\n')
......@@ -644,7 +654,12 @@ def write_monitor(scope):
scope.output.write(' Type: %s\n' % type_string)
# Name current found as name item instead of att.name()
name_item = att.findString('Name')
scope.output.write(' Name: %s\n' % name_item.value(0))
name = name_item.value(0)
if not name:
msg = 'Cannot export because there is a %s monitor with an empty name field ' % type_string
raise Exception(msg)
scope.output.write(' Name: %s\n' % name)
# Voltage Monitor a special case
if type_string == 'ModeVoltage':
......@@ -662,6 +677,21 @@ def write_monitor(scope):
else:
scope.output.write(' %s: %s\n' % (keyword, item.value(0)))
# PowerMonitor can use analysis end time and interval if not set here
if type_string == 'Power':
# Get FEInfo, which provides the default values if needed
feinfo_att = scope.sim_atts.findAttributes('FEInfo')[0]
time_end_item = att.findDouble('TimeEnd')
if not time_end_item.isEnabled():
max_time = feinfo_att.findDouble('MaxTime').value(0)
scope.output.write(' %s: %g\n' % ('TimeEnd', max_time))
time_step_item = att.findDouble('TimeStep')
if not time_step_item.isEnabled():
dt = feinfo_att.findDouble('DT').value(0)
scope.output.write(' %s: %g\n' % ('TimeStep', dt))
# Handle MonitorBoundary as special case
boundary_item = att.findModelEntity('MonitorBoundary')
if boundary_item is not None:
......
......@@ -124,15 +124,15 @@ the distance from the front of the bunch and greater than 0</BriefDescription>
<DefaultValue>0.0</DefaultValue>
<RangeInfo><Min Inclusive="true">0</Min></RangeInfo>
</Double>
<Double Name="timeEnd" Label="End Time" Units="s">
<BriefDescription>Time when recording power ends</BriefDescription>
<Double Name="TimeEnd" Label="End Time" Units="s" Optional="true" IsEnabledByDefault="false">
<BriefDescription>Time when recording power ends. If not enabled here, analysis end time is used.</BriefDescription>
<Categories>
<Cat>T3P</Cat>
</Categories>
<RangeInfo><Min Inclusive="true">0</Min></RangeInfo>
</Double>
<Double Name="TimeStep" Label="Time Interval" Units="s">
<BriefDescription>Time interval for recornding power</BriefDescription>
<Double Name="TimeStep" Label="Time Interval" Units="s" Optional="true" IsEnabledByDefault="false">
<BriefDescription>Time interval for recornding power. If not enabled here, analysis time interval is used.</BriefDescription>
<Categories>
<Cat>T3P</Cat>
</Categories>
......
# Test Conditions in t3p-test2.crf
This test case adds
* Mode voltage monitor
* Power monitor
* Automatic moving window
## Model
......@@ -50,3 +51,8 @@ Mode Voltage Monitor --> New
* Name ----------------> modecoeff
* Monitor Port --------> side set 5
Power Monitor ---------> New
* Name ----------------> power
* Monitor Boundary ----> side set 1
* End Time ------------> NOT checked
* Time Intervals ------> 2e-12
// Generated by CMB 05-Jun-2018 15:05
// Generated by CMB 03-Jul-2018 16:51
ModelInfo:
{
File: pillboxwg.ncdf
......@@ -88,6 +88,16 @@ Monitor:
}
}
Monitor:
{
Type: Power
Name: power
TimeStart: 0.0
TimeStep: 2e-12
TimeEnd: 5e-09
ReferenceNumber: 1
}
LinearSolver:
{
Solver: MUMPS
......
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