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).

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.

Cart3D executive class: cape.pycart.cntl.Cntl

class cape.pycart.cntl.Cntl(fname=None)

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

Outputs:
cntl: cape.pycart.cntl.Cntl

Instance of the pyCart control class

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

Versions:
  • 2014-05-28 @ddalle : v1.0

  • 2014-06-03 @ddalle : Renamed class Cntl –> Cart3d

  • 2014-06-30 @ddalle : Reduced number of data members

  • 2014-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.

Call:
>>> cntl.ApplyCase(i, nPhase=None)
Inputs:
cntl: cape.pyfun.cntl.Cntl

Cart3D control interface

i: int

Case number

nPhase: {None} | positive int

Last phase number (default determined by PhaseSequence)

Versions:
  • 2016-03-31 @ddalle: v1.0

ApplyFlowCartSettings(**kw)

Apply settings from cntl.opts to a set of cases

This rewrites case.json 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

Versions:
  • 2014-12-11 @ddalle: v1.0

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

Versions:
  • 2015-01-11 @ddalle: v1.0

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)

Outputs:
q: bool

Whether or not the mesh for case i is prepared

Versions:
  • 2014-09-29 @ddalle: v1.0

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

Versions:
  • 2015-09-27 @ddalle: v1.0

  • 2017-02-22 @ddalle: Added verbose flag

ExplodeTri()

Create a 3-view of each named or numbered comp 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 inf Config.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

Versions:
  • 2015-01-23 @ddalle: v1.0

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} | positive int

Add n times steps to the total iteration count

j: {None} | nonnegative int

Apply to phase j, by default use the last phase

imax: {None} | nonnegative int

Use imax as the maximum iteration count

Versions:
  • 2017-03-31 @ddalle: v1.0

  • 2021-12-09 @ddalle: v1.1; bug fixes

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

Outputs:
rho: float

Non-dimensional static density, rho/rhoinf

U: float

Non-dimensional velocity, U/ainf

p: float

Non-dimensional static pressure, p/pinf

Versions:
  • 2016-03-28 @ddalle: v1.0

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

Outputs:
rho: float

Non-dimensional static density, rho/rhoinf

U: float

Non-dimensional velocity, U/ainf

p: float

Non-dimensional static pressure, p/pinf

Versions:
  • 2016-11-21 @ddalle: v1.0

PrepareAeroCsh(i: int)

Write aero.csh for run case i

Call:
>>> cntl.PrepareAeroCsh(i)
Inputs:
cntl: cape.pycart.cntl.Cntl

Instance of global pyCart settings object

i: int

Run index

Versions:
  • 2014-06-10 @ddalle: v1.0

  • 2014-10-03 @ddalle: v2.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

Versions:
  • 2014-09-30 @ddalle: v1.0

  • 2022-04-13 @ddalle: v1.1; exec_modfunction()

  • 2024-01-16 @ddalle: v1.2; case func b4 writeJSON

PrepareInputCntl(i: int)

Write input.cntl for run case i

Call:
>>> cntl.PrepareInputCntl(i)
Inputs:
cntl: cape.pycart.cntl.Cntl

Instance of global pyCart settings object

i: int

Run index

Versions:
  • 2014-06-04 @ddalle: v1.0

  • 2014-06-06 @ddalle: v1.1; low-level griddir support

  • 2014-09-30 @ddalle: v1.2; change to 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)

Versions:
  • 2014-09-29 @ddalle: v1.0

PreparePreSpecCntl()

Prepare and write preSpec.c3d.cntl in current folder

Call:
>>> cntl.PreparePreSpecCntl()
Inputs:
cntl: cape.pycart.cntl.Cntl

Instance of global pyCart settings object

See Also:
Versions:
  • 2014-10-08 @ddalle: v1.0

ReadAeroCsh()

Read the aero.csh file

Call:
>>> cntl.ReadAeroCsh()
Inputs:
cntl: cape.pycart.cntl.Cntl

Instance of global pyCart settings object

Versions:
  • 2015-10-14 @ddalle: Revived from deletion

ReadInputCntl()

Read the input.cntl file

Call:
>>> cntl.ReadInputCntl()
Inputs:
cntl: cape.pycart.cntl.Cntl

Instance of global pyCart settings object

Versions:
  • 2015-06-13 @ddalle: v1.0

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)

Versions:
  • 2016-03-28 @ddalle: v1.0

  • 2016-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

Versions:
  • 2014-11-14 @ddalle: v1.0

  • 2014-12-10 @ddalle: v1.1; add 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

Versions:
  • 2014-12-18 @ddalle: v1.0

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

Versions:
  • 2015-04-12 @ddalle: v1.0

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'

Versions:
  • 2016-01-13 @ddalle: v1.0

WritePBS(i: int)

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

Versions:
  • 2014-09-30 @ddalle: v1.0

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

Outputs:
cmd: None | str

Name of command that was processed, if any

Versions:
  • 2018-10-19 @ddalle: v1.0