cape.pylava.runinpfile: Interface to LAVA-Cartesian input files

This module provides the class CartInputFile, which is used to parse and modify the C-like input file to LAVA-Cartesian

class cape.pylava.runinpfile.CartFileList(opt: str, fp: IOBase | None = None)

Reader for a “list” of LAVA-Cartesian input files

This refers to list-like contents of [] brackets, e.g.

[
    mach,
    cp
]
Call:
>>> sec = CartFileList(opt, fp)
Inputs:
opt: str

Name of option on left-hand side, used for error messages

fp: IOBase

File open for reading at start of section

class cape.pylava.runinpfile.CartFileSection(sec: str, fp: IOBase | None = None)

Reader for a “section” of LAVA-Cartesian input files

This refers to dict-like contents of {} braces, e.g.

{
    mach = 4.5
    alpha = 2.0
}
Call:
>>> sec = CartFileSection(sec, fp)
Inputs:
sec: str

Name of section, used for error messages

fp: IOBase

File open for reading at start of section

class cape.pylava.runinpfile.CartInputFile(fname: str | None = None)

Interface to LAVA-Cartesian input files

Call:
>>> inp = CartInputFile(fname=None)
Inputs:
fname: {None} | str

Name of input file

Outputs:
inp: CartInputFile

Interface to one LAVA-Cartesian input file

apply_dict(d: dict, parent: str | None = None)

Apply a dict of options to run.inputs interface

Call:

>>. opts.apply_dict(d, parent=None)

Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

d: dict

Dictionary of options to apply

parent: {None} | str

Used for recursion

Versions:
  • 2025-07-16 @ddalle: v1.0

get_alpha()

Get freestream angle of attack

Call:
>>> a = opts.get_alpha()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
a: float

Angle of attack [deg]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_beta() → float

Set freestream sideslip angle

Call:
>>> b = opts.set_beta()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
b: float

Sideslip angle [deg]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_density() → float

Get freestream static density

Call:
>>> rho = opts.get_density()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
rho: float

Static density [kg/m^3]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_nstep() → int

Get number of time steps to take

Call:
>>> n = opts.get_nstep()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
n: int

Number of time steps to take

Versions:
  • 2025-05-09 @ddalle: v1.0

get_opt(sec: str, opt: str, vdef=None) → Any

Get value of an option

You can use . in opt ot access subsections. For example

opts.get_opt("cartesian", "output.surface.frequency")
Call:
>>> v = opts.get_opt(sec, opt, vdef=None)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

sec: str

Name of section

opt: str

Name of option or subsection(s) and option

vdef: {None} | object

Default value if opt is not set

Outputs:
val: object

Value of opt

Versions:
  • 2025-05-07 @ddalle: v1.0

get_pressure() → float

Get freestream static pressure

Call:
>>> p = opts.get_pressure()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
p: float

Static pressure [Pa]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_refarea() → float

Get solution reference area

Call:
>>> aref = opts.set_reflength()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
aref: float

Reference area [m^2]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_refcond(opt: str) → Any

Get option from reference conditions section

Call:
>>> v = opts.get_refcond(opt)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

opt: str

Name of option within section

Outputs:
v: object

Value of the option

Versions:
  • 2025-05-09 @ddalle: v1.0

get_refdx() → float

Set solution reference grid size

Call:
>>> opts.set_refdx(dx)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
ds: float

Reference grid scale [m]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_reflength() → float

Get solution reference length

Call:
>>> lref = opts.set_reflength(lref)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
lref: float

Reference length [m]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_temperature() → float

Get freestream static temperature

Call:
>>> t = opts.get_temperature()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
t: float

Static temperature [K]

Versions:
  • 2025-05-09 @ddalle: v1.0

get_uref() → float

Set solution reference velocity

Call:
>>> uref = opts.get_uref()
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

Outputs:
uref: float

Reference velocity [m/s]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_alpha(a: float)

Set freestream angle of attack

Call:
>>> opts.set_alpha(a)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

a: float

Angle of attack [deg]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_beta(b: float)

Set freestream sideslip angle

Call:
>>> opts.set_beta(b)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

b: float

Sideslip angle [deg]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_density(r: float)

Set freestream static density

Call:
>>> opts.set_density(r)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

r: float

Static density [kg/m^3]

Versions:
  • 2025-07-15 @ddalle: v1.0

set_mach(m: float)

Set freestream Mach number

Call:
>>> opts.set_mach(m)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

m: float

Mach number

Versions:
  • 2025-07-15 @ddalle: v1.0

set_nstep(n: int)

Set number of time steps to take

Call:
>>> opts.set_nstep(n)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

n: int

Number of time steps to take

Versions:
  • 2025-05-09 @ddalle: v1.0

set_opt(sec: str, opt: str, val: Any)

Set value of an option

You can use . in opt ot access subsections. For example

opts.set_opt("cartesian", "output.surface.frequency", 50)
Call:
>>> v = opts.set_opt(sec, opt, val)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

sec: str

Name of section

opt: str

Name of option or subsection(s) and option

val: object

Value of opt to set

Versions:
  • 2025-05-07 @ddalle: v1.0

set_pressure(p: float)

Set freestream static pressure

Call:
>>> opts.set_pressure(p)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

p: float

Static pressure [Pa]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_refarea(aref: float)

Set solution reference length

Call:
>>> opts.set_reflength(aref)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

aref: float

Reference area [m^2]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_refcond(opt: str, v: Any)

Set option in reference conditions section

Call:
>>> opts.set_refcond(opt, v)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

opt: str

Name of option within section

v: object

Value of the option

Versions:
  • 2025-05-09 @ddalle: v1.0

set_refdx(dx: float)

Set solution reference grid size

Call:
>>> opts.set_refdx(dx)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

ds: float

Reference grid scale [m]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_reflength(lref: float)

Set solution reference length

Call:
>>> opts.set_reflength(lref)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

lref: float

Reference length [m]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_temperature(t: float)

Set freestream static temperature

Call:
>>> opts.set_pressure(p)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

t: float

Static temperature [K]

Versions:
  • 2025-05-09 @ddalle: v1.0

set_uref(uref: float)

Set solution reference velocity

Call:
>>> opts.set_uref(uref)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

uref: float

Reference velocity [m/s]

Versions:
  • 2025-05-09 @ddalle: v1.0

write(fname: str | None = None)

Write contents to .vars file

Call:
>>> opts.write(fname=None)
Inputs:
opts: CartInputFile

LAVA-cartesian input file interface

fname: {None} | str

File name to write

Versions:
  • 2025-07 @ddalle: v1.0

cape.pylava.runinpfile.assert_nextstr(c: str, target: str, desc=None)

Check if a string matches a specified target

Call:
>>> assert_nextstr(c, target, desc=None)
Inputs:
c: str

Any string

target: str

Target value for c

desc: {None} | str

Optional description for what is being tested

Raises:
Versions:
  • 2024-02-23 @ddalle: v1.0

cape.pylava.runinpfile.assert_regex(c: str, regex, desc=None)

Check if a string matches a compiled regular expression

Call:
>>> assert_regex(c, regex, desc=None)
Inputs:
c: str

Any string

regex: re.Pattern

A compiled regular expression

desc: {None} | str

Optional description for what is being tested

Raises:
Versions:
  • 2024-02-23 @ddalle: v1.0

cape.pylava.runinpfile.to_text(val: object, indent: int = 0) → str

Convert appropriate Python value to .vars file text

Call:
>>> txt = to_text(val, indent=0)
Inputs:
val: object

One of several appropriate values for .vars files

indent: {0} | int

Number of levels of indentation

Outputs:
txt: str

Converted text

Versions:
  • 2025-05-07 @ddalle: v1.0

cape.pylava.runinpfile.to_val(txt: str)

Convert .vars file text to a Python value

This only applies to single entries and does not parse lists, etc.

Call:
>>> v = to_val(txt)
Inputs:
txt: str

Any valid text for a single value in a .vars file

Outputs:
v: object

Interpreted value, number, string, boolean, or None

Versions:
  • 2025-05-07 @ddalle: v1.0

  • 2025-05-19 @ddalle: v1.1; support ['a'^3] syntax