Welcome to PyQBMMlib’s documentation!

TOC Tree

Drivers

These are example drivers that you may use as templates for your application.

devel_driver.advance_example(config)

This driver solves the moments transport equations. It is independent of governing dynamics, which are specified in the config dictionary. It is constrained to problems with 1 and 2 internal coordinates by the initial condition. The initial condition is Gaussian.

Parameters

config (dict) – Configuration dictionary

devel_driver.advance_example2dp1()
devel_driver.flow_example()

This driver solves a flow-coupled problem. Currently, it only computes moment fluxes, but work is underway to solve the compressible flow equations.

Advancer

class advancer.time_advancer(config)

Bases: object

This class advances the moment transport equations in time.

A config dictionary is required to usethis class. Example files are provided in inputs/. The dictionary is used to set the following variables:

Variables
  • method – Time integration scheme (euler or RK3)

  • time_step – Time integration time step

  • final_time – Final integration time

  • num_steps – Number of integration steps

  • num_steps_print – Report-status frequency

  • num_steps_write – Write-to-file frequency

  • output_dir – Directory to which output is written

  • output_id – An ID for each run’s output file

Create an advancer object simply by typing

>>> advancer = time_advancer( config )

Before running, you’ll need to initialize the state. One way you may do this is through:

>>> advancer.initialize_state_gaussian_univar( mu, sigma )

for a 1D problem, where mu and sigma are user-specified. Now all you have to do is:

>>> advancer.run()
adapt_time_step()

This function adapts the time step according to user-specified tolerance

advance_RK3()

This function advances the state with a Runge–Kutta 2/3 scheme

advance_euler()

This function advances the state with an explicit Euler scheme

initialize_state(init_state)

This function initializes the advancer state

Parameters

init_state (array like) – Initial condition

initialize_state_gaussian_bivar(mu1, mu2, sigma1, sigma2)

This function initializes the state to the raw moments of a bivariate Gaussian distribution.

Parameters
  • mu1 (float) – Mean of coordinate 1

  • mu2 (float) – Mean of coordinate 2

  • sig1 (float) – Standard deviation of coordinate 1

  • sig2 (float) – Standard deviation of coordinate 2

initialize_state_gaussian_trivar(mu1, mu2, mu3, sig1, sig2, sig3)

This function initializes the state to the raw moments of a trivariate Gaussian distribution.

Parameters
  • mu1 (float) – Mean of coordinate 1

  • mu2 (float) – Mean of coordinate 2

  • mu3 (float) – Mean of coordinate 3

  • sig1 (float) – Standard deviation of coordinate 1

  • sig2 (float) – Standard deviation of coordinate 2

  • sig3 (float) – Standard deviation of coordinate 3

initialize_state_gaussian_univar(mu, sigma)

This function initializes the state to the raw moments of a univariate Gaussian distribution.

Parameters
  • mu – Mean

  • sigma – Standard deviation

report_step(i_step)

This function reports the current state

Parameters

i_step (int) – Current step

run()

Advancer driver

write_step(i_step)

This function writes the current state

Parameters

i_step (int) – Current step

write_to_h5()

This function writes the current state to a h5 file, but is not implemented yet.

write_to_txt(i_step)

This function writes the current state to a txt file

Parameters

i_step (int) – Current step

QBMM Manager

class qbmm_manager.qbmm_manager(config)

Bases: object

This class manages the computation of moment-transport RHS. It is meant to be called from within time_advancer, with which it interfaces through compute_rhs(). The config dictionary carries values for the following variables:

Variables
  • dynamics (governing) – Governing internal dynamics

  • num_internal_coords – Number of internal coordinates

  • num_quadrature_nodes – Number of quadrature nodes

  • method – Inversion method (qmom, hyqmom, chyqmom)

  • adaptive – Adaptivity flag for method = qmom (Wheeler)

  • max_skewness – Maximum skewness for method = hyqmom or chyqmom (hyperbolic or conditional hyperbolic)

compute_rhs(moments, rhs)

This function computes moment-transport RHS

Parameters
  • moments – Transported moments

  • rhs – Moments rate-of-change

moment_indices()

This function sets moment indices according to dimensionality (num_coords and num_nodes) and method.

moment_invert_1D(moments)

This function inverts tracked moments into a quadrature rule in 1D

Parameters

moments (array like) – Tracked moments

Returns

quadrature abscissas, weights

Return type

array like

This is never directly invoked. Instead, the user calls

>>> xi, wts = qbmm_mgr.moment_inver(moments)

and qbmm_manager automatically selects moment_invert_1D based if num_internal_coords = 1

moment_invert_2PD(moments)

This function inverts moments into a quadrature rule in ND > 1

Parameters

moments (array like) – Tracked moments

Returns

quadrature abscissas, weights

Return type

array like

This is never directly invoked. Instead, the user calls

>>> xi, wts = qbmm_mgr.moment_inver(moments)

and qbmm_manager automatically selects moment_invert_2PD based if num_internal_coords > 1

projection(weights, abscissas, indices)

This function reconstructs moments (indices) from quadrature weights and abscissas

Parameters
  • weights (array like) – Quadrature weights

  • abscissas (array like) – Quadrature abscissas

  • indices – Full moment set indices

Returns

projected moments

Return type

array like

set_inversion(config)

This function sets the inversion procedure based on config options

Parameters

config (dict) – Configuration

transport_terms()

This function determines the RHS in the moments equation for a given governing dynamics

Inversion

inversion.chyqmom27(moments, indices, max_skewness=30, checks=True)
inversion.chyqmom4(moments, indices, max_skewness=30)
inversion.chyqmom9(moments, indices, max_skewness=30, checks=True)
inversion.conditional_hyperbolic(moments, indices, max_skewness=30, checks=True)

This function inverts moments into a two-node quadrature rule.

Parameters

moments (array like) – Statistical moments of the transported PDF

Returns

Abscissas, weights

Return type

array like

inversion.hyperbolic(moments, max_skewness=30, checks=True)

This is a driver for hyperbolic qmom. It calls hyqmom2() if len(moments) = 2, or hyqmom3() if len(moments) = 3

Parameters
  • moments (array like) – Statistical moments of the transported PDF

  • max_skewness (float) – Maximum skewness (optional, defaults to 30)

Returns

Abscissas, weights

Return type

array like

inversion.hyqmom2(moments)

This function inverts moments into a two-node quadrature rule.

Parameters

moments (array like) – Statistical moments of the transported PDF

Returns

Abscissas, weights

Return type

array like

inversion.hyqmom3(moments, max_skewness=30, checks=True)

This function inverts moments into a three-node quadrature rule.

Parameters
  • moments (array like) – Statistical moments of the transported PDF

  • max_skewness (float) – Maximum skewness

Returns

Abscissas, weights

Return type

array like

inversion.sign(q)
inversion.wheeler(moments, adaptive=False)

This function inverts moments into 1D quadrature weights and abscissas using adaptive Wheeler algorithm.

Parameters

moments (array like) – Statistical moments of the transported PDF

Returns

Abscissas, weights

Return type

array like

Indices and tables