cape.pycart.cntl
: Cart3D control module¶
This module provides tools to quickly setup basic Cart3D runs or a complex Cart3D setup from a small set of input files. Alternatively, the methods and classes can be used to help setup a problem that is too complex or customized to conform to standardized script libraries. A collection of cases combined into a run matrix can be loaded using the following commands.
>>> import cape.pycart.cart3d >>> cntl = cape.pycart.cntl.Cntl("pyCart.json") >>> cntl <cape.pycart.Cntl(nCase=4, tri='bullet.tri')> >>> cntl.x.GetFullFolderNames(0) 'poweroff/m1.5a0.0b0.0'
An instance of this cape.pycart.cntl.Cntl
class has many
attributes, which include the run matrix (cntl.x
), the options
interface (cntl.opts
), and optionally the data book
(cntl.DataBook
), the triangulation (cntl.tri
), and the
appropriate input files (such as cntl.InputCntl
).
Attribute
Class
cntl.x
cntl.opts
cntl.tri
cntl.DataBook
cntl.InputCntl
cntl.AeroCsh
Finally, the cape.pycart.cntl.Cntl
class is subclassed from the
cape.cntl.Cntl
class, so any methods available to the CAPE class are
also available here.
- class cape.pycart.cntl.Cntl(fname='pyCart.json')¶
Class for handling global options and setup for Cart3D
This class is intended to handle all settings used to describe a group of Cart3D cases. The settings are read from a JSON file.
- Call:
>>> cntl = cape.pycart.Cntl(fname="pyCart.json")
- Inputs:
- fname:
str
Name of pyCart input file
- fname:
- Outputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of the pyCart control class
- cntl:
- Data members:
- cntl.opts:
dict
Dictionary of options for this case (directly from fname)
- cntl.x:
cape.runmatrix.RunMatrix
Values and definitions for variables in the run matrix
- cntl.RootDir:
str
Absolute path to the root directory
- cntl.opts:
- Versions:
2014-05-28
@ddalle
: First version2014-06-03
@ddalle
: Renamed class Cntl –> Cart3d2014-06-30
@ddalle
: Reduced number of data members2014-07-27
@ddalle
: cart3d.RunMatrix –> cart3d.x
- ApplyCase(i, nPhase=None, **kw)¶
Apply settings from cntl.opts to an individual case
This rewrites each run namelist file and the
case.json
file in the specified directories. It can also be used to- Call:
>>> cntl.ApplyCase(i, nPhase=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl
Cart3D control interface
- i:
int
Case number
- nPhase: {
None
} | positiveint
Last phase number (default determined by PhaseSequence)
- cntl:
- Versions:
2016-03-31
@ddalle
: First version
- ApplyFlowCartSettings(**kw)¶
Apply settings from cntl.opts to a set of cases
This rewrites the
case.json
file in the specified directories.- Call:
>>> cntl.ApplyFlowCartSettings(cons=[])
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- I:
list
[int
] List of indices
- cons:
list
[str
] List of constraints
- cntl:
- Versions:
2014-12-11
@ddalle
: First version
- ArchiveCases(**kw)¶
Archive completed cases and clean them up if specified
- Call:
>>> cntl.ArchiveCases() >>> cntl.ArchiveCases(cons=[], **kw)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- I:
list
[int
] List of indices
- cons:
list
[str
] List of constraints
- cntl:
- Versions:
2015-01-11
@ddalle
: First version
- CaseGetCurrentIter()¶
Get the current iteration number from the appropriate module
This function utilizes the
cape.case
module, and so it must be copied to the definition for each solver’s control class- Call:
>>> n = cntl.CaseGetCurrentIter()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- i:
int
Index of the case to check (0-based)
- cntl:
- Outputs:
- n:
int
orNone
Number of completed iterations or
None
if not set up
- n:
- Versions:
2015-10-14
@ddalle
: First version
- CaseGetCurrentPhase()¶
Get the current phase number from the appropriate module
This function utilizes the
cape.case
module, and so it must be copied to the definition for each solver’s control class- Call:
>>> j = cntl.CaseGetCurrentPhase()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- i:
int
Index of the case to check (0-based)
- cntl:
- Outputs:
- j:
int
|None
Phase number
- j:
- Versions:
2017-06-29
@ddalle
: First version
- CaseStartCase()¶
Start a case by either submitting it or running it
This function relies on
cape.pycart.case
, and so it is customized for the Cart3D solver only in that it calles the correct case module.- Call:
>>> pbs = cntl.CaseStartCase()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- cntl:
- Outputs:
- pbs:
int
orNone
PBS job ID if submitted successfully
- pbs:
- Versions:
2015-10-14
@ddalle
: First version
- CheckMesh(i)¶
Check if the mesh for case i is prepared.
- Call:
>>> q = cntl.CheckMesh(i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- i:
int
Index of the case to check (0-based)
- cntl:
- Outputs:
- q:
bool
Whether or not the mesh for case i is prepared
- q:
- Versions:
2014-09-29
@ddalle
: First version
- CheckNone(v=False)¶
Check if the current folder has the necessary files to run
- Call:
>>> q = cntl.CheckNone(v=False)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- v:
True
| {False
} Verbose flag; prints message if q is
True
- cntl:
- Versions:
2015-09-27
@ddalle
: First version2017-02-22
@ddalle
: Added verbose flag
- ExplodeTri()¶
Create a 3-view of each named or numbered component using TecPlot
This will create a folder called
subtri/
in the master directory for this cntl object, and it will contain a triangulation for each named component infConfig.xml
along with a three-view plot of each component created using TecPlot if possible.- Call:
>>> cntl.ExplodeTri()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- cntl:
- Versions:
2015-01-23
@ddalle
: First version
- ExtendCase(i, n=1, j=None, imax=None)¶
Extend the number of iterations for which a case should run
- Call:
>>> cntl.ExtendCase(i, n=1, j=None, imax=None)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of pyCart control class
- i:
int
Run index
- n: {
1
} | positiveint
Add n times steps to the total iteration count
- j: {
None
} | nonnegativeint
Apply to phase j, by default use the last phase
- imax: {
None
} | nonnegativeint
Use imax as the maximum iteration count
- cntl:
- Versions:
2017-03-31
@ddalle
: Version 1.02021-12-09
@ddalle
: Version 1.1; bug fixes
- GetCPUTime(i, running=False)¶
Read a CAPE-style core-hour file from a case
- Call:
>>> CPUt = cntl.GetCPUTime(i, running=False)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Cart3D control interface
- i:
int
Case index
- running:
True
| {False
} Whether or not to check for time since last start
- cntl:
- Outputs:
- CPUt:
float
|None
Total core hours used in this job
- CPUt:
- Versions:
2015-12-22
@ddalle
: First version2016-08-31
@ddalle
: Checking time since most recent start
- GetSurfBCState(key, i)¶
Get surface boundary condition state
- Call:
>>> rho, U, p = cntl.GetSurfBCState(key, i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- key:
str
Name of key to process
- i:
int
Run index
- cntl:
- Outputs:
- rho:
float
Non-dimensional static density, rho/rhoinf
- U:
float
Non-dimensional velocity, U/ainf
- p:
float
Non-dimensional static pressure, p/pinf
- rho:
- Versions:
2016-03-28
@ddalle
: First version
- GetSurfCTState(key, i)¶
Get surface boundary state from thrust coefficient
- Call:
>>> rho, U, p = cntl.GetSurfCTState(key, i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- key:
str
Name of key to process
- i:
int
Run index
- cntl:
- Outputs:
- rho:
float
Non-dimensional static density, rho/rhoinf
- U:
float
Non-dimensional velocity, U/ainf
- p:
float
Non-dimensional static pressure, p/pinf
- rho:
- Versions:
2016-11-21
@ddalle
: First version
- PrepareAeroCsh(i)¶
Write
aero.csh
for run case i in the appropriate folder and with the appropriate settings.- Call:
>>> cntl.PrepareAeroCsh(i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- i:
int
Run index
- cntl:
- Versions:
2014-06-10
@ddalle
: First version2014-10-03
@ddalle
: Version 2.0
- PrepareCase(i)¶
Prepare case for running if necessary
- Call:
>>> cntl.PrepareCase(i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- i:
int
Index of case to analyze
- cntl:
- Versions:
2014-09-30
@ddalle
: v1.02022-04-13
@ddalle
: v1.1; exec_modfunction()2024-01-16
@ddalle
: v1.2; case func b4 writeJSON
- PrepareInputCntl(i)¶
Write
input.cntl
for run case i in the appropriate folder and with the appropriate settings.- Call:
>>> cntl.PrepareInputCntl(i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- i:
int
Run index
- cntl:
- Versions:
2014-06-04
@ddalle
: First version2014-06-06
@ddalle
: Low-level functionality for grid folders2014-09-30
@ddalle
: Changed to write only a single case
- PrepareMesh(i)¶
Prepare the mesh for case i if necessary.
- Call:
>>> cntl.PrepareMesh(i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- i:
int
Index of the case to check (0-based)
- cntl:
- Versions:
2014-09-29
@ddalle
: First version
- PreparePreSpecCntl()¶
Prepare and write
preSpec.c3d.cntl
according to the current settings and in the current folder.- Call:
>>> cntl.PreparePreSpecCntl()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- cntl:
- See Also:
- Versions:
2014-10-08
@ddalle
: First version
- ReadAeroCsh()¶
Read the
aero.csh
file- Call:
>>> cntl.ReadAeroCsh()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- cntl:
- Versions:
2015-10-14
@ddalle
: Revived from deletion
- ReadCaseJSON(i)¶
Read
case.json
file from case i if possible- Call:
>>> rc = cntl.ReadCaseJSON(i)
- Inputs:
- ofl:
cape.pyfun.cntl.Cntl
Instance of FUN3D control class
- i:
int
Run index
- ofl:
- Outputs:
- rc:
None
|pyOver.options.runControl.RunControl
Run control interface read from
case.json
file
- rc:
- Versions:
2016-12-12
@ddalle
: First version2017-03-31
@ddalle
: Copied fromcape.pyover
- ReadDataBook(comp=None)¶
Read the current data book
- Call:
>>> cntl.ReadDataBook(comp=None)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- comp: {
None
} |str
|list
List of components, or read all if
None
- cntl:
- Versions:
2014-12-28
@ddalle
: First version2017-04-27
@ddalle
: Added comp option
- ReadInputCntl()¶
Read the
input.cntl
file- Call:
>>> cntl.ReadInputCntl()
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- cntl:
- Versions:
2015-06-13
@ddalle
: First version
- ReadReport(rep)¶
Read a report interface
- Call:
>>> R = cntl.ReadReport(rep)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- rep:
str
Name of report
- cntl:
- Outputs:
- R:
pyFun.report.Report
Report interface
- R:
- Versions:
2018-10-19
@ddalle
: First version
- SetSurfBC(key, i, CT=False)¶
Set all SurfBCs for a particular thrust trajectory key
- Call:
>>> cntl.SetSurfBC(key, i, CT=False)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- key:
str
Name of key to process
- i:
int
Run index
- CT:
True
| {False
} Inputs of thrust (
True
) or pressure (False
)
- cntl:
- Versions:
2016-03-28
@ddalle
: First version2016-11-21
@ddalle
: Added CT input key
- TarAdapt(**kw)¶
Tar
adaptNN/
folders except for most recent one- Call:
>>> cntl.TarAdapt() >>> cntl.TarAdapt(cons=[])
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- I:
list
[int
] List of indices
- cons:
list
[str
] List of constraints
- cntl:
- Versions:
2014-11-14
@ddalle
: First version2014-12-10
@ddalle
: Added constraints
- TarViz(**kw)¶
Tar
adaptNN/
folders except for most recent one- Call:
>>> cntl.TarViz() >>> cntl.TarViz(cons=[], **kw)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- I:
list
[int
] List of indices
- cons:
list
[str
] List of constraints
- cntl:
- Versions:
2014-12-18
@ddalle
: First version
- UntarAdapt(**kw)¶
Tar
adaptNN/
folders except for most recent one- Call:
>>> cntl.UntarAdapt() >>> cntl.UntarAdapt(cons=[])
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of global pyCart settings object
- I:
list
[int
] List of indices
- cons:
list
[str
] List of constraints
- cntl:
- Versions:
2015-04-12
@ddalle
: First version
- UpdatePointSensor(**kw)¶
Update point sensor group(s) data book
- Call:
>>> cntl.UpdatePointSensor(pt=None, cons=[], **kw)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- pt:
str
Optional name of point sensor group to update
- I:
list
[int
] List of indices
- cons:
list
[str
] List of constraints like
'Mach<=0.5'
- cntl:
- Versions:
2016-01-13
@ddalle
: First version
- WritePBS(i)¶
Write the PBS script for a given case
- Call:
>>> cntl.WritePBS(i)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- i:
int
Run index
- cntl:
- Versions:
2014-09-30
@ddalle
: First version
- cli(*a, **kw)¶
Command-line interface
- Call:
>>> cntl.cli(*a, **kw)
- Inputs:
- cntl:
cape.pycart.cntl.Cntl
Instance of control class containing relevant parameters
- kw:
dict
(True
|False
|str
) Unprocessed keyword arguments
- cntl:
- Outputs:
- cmd:
None
|str
Name of command that was processed, if any
- cmd:
- Versions:
2018-10-19
@ddalle
: Content frombin/
executables