PyART.numerical.twopuncts_ID

Attributes

Classes

LinearScaler

Class to perform linear transformation and its inverse

TwoPunctID

Class to setup initial data computation

Module Contents

PyART.numerical.twopuncts_ID.file_path = b'.'[source]
PyART.numerical.twopuncts_ID.file_dir[source]
PyART.numerical.twopuncts_ID.DUMMY[source]
class PyART.numerical.twopuncts_ID.LinearScaler(A, B, C, D)[source]

Class to perform linear transformation and its inverse between two intervals [A,B] and [C,D]

A[source]
B[source]
C[source]
D[source]
transform(x)[source]

Transform x from interval [A,B] to [C,D].

Parameters:

x (float or array-like) – Value(s) in the original interval [A,B] to be transformed.

Returns:

Transformed value(s) in the target interval [C,D].

Return type:

float or array-like

inverse_transform(y)[source]

Inverse transform y from interval [C,D] to [A,B].

Parameters:

y (float or array-like) – Value(s) in the target interval [C,D] to be inverse transformed.

Returns:

Inverse transformed value(s) in the original interval [A,B].

Return type:

float or array-like

__lin_transf(A, B, C, D, x)[source]

Apply linear transformation from [A,B] to [C,D].

Parameters:
  • A (float) – Lower bound of the original interval.

  • B (float) – Upper bound of the original interval.

  • C (float) – Lower bound of the target interval.

  • D (float) – Upper bound of the target interval.

  • x (float or array-like) – Value(s) to be transformed.

Returns:

Transformed value(s).

Return type:

float or array-like

class PyART.numerical.twopuncts_ID.TwoPunctID(**kwargs)[source]

Bases: object

Class to setup initial data computation using the TwoPunctures code. See: https://github.com/computationalrelativity/TwoPuncturesC

M = 1.0[source]
q = 1.0[source]
E = 1.1[source]
E_min = None[source]
L = 1.0[source]
D = 100[source]
chi1z = 0.0[source]
chi2z = 0.0[source]
npoints_A = 8[source]
npoints_B = 8[source]
npoints_phi = 6[source]
TP_dummy[source]
TP_exe = './TwoPunctures.x'[source]
outdir = './'[source]
verbose = False[source]
iteration = None[source]
TP_pars[source]
TP_int_vars = ['npoints_A', 'npoints_B', 'npoints_phi', 'give_bare_mass'][source]
create_TP_parfile(P, parfile=None, outdir=None)[source]

Create a parameter file for TwoPunctures with given momentum P. Assumes L along z axis and initial separation along x axis.

Parameters:
  • P (float) – Magnitude of the linear momentum for each puncture.

  • parfile (str or None, optional) – Name of the parameter file to create (default is None, which uses “parfile_P{P:.10f}.par”).

  • outdir (str or None, optional) – Output directory to save the parameter file (default is None, which uses self.outdir).

Returns:

Path to the created parameter file.

Return type:

str

run_TP_from_parfile(parfile)[source]

Run TwoPunctures with the given parameter file. :param parfile: Path to the parameter file to use. :type parfile: str

Returns:

Path to the output file generated by TwoPunctures.

Return type:

str

read_TP_output(outfile)[source]

Read the output file from TwoPunctures and extract E_ADM, M1, and M2.

Parameters:

outfile (str) – Path to the output file generated by TwoPunctures.

Returns:

  • E_ADM (float) – Total ADM energy.

  • M1 (float) – ADM mass of puncture 1.

  • M2 (float) – ADM mass of puncture 2.

run_TP_wrapper(P, parfile=None, verbose=None)[source]

Run the full TwoPunctures workflow: create parfile, run TP, read output. :param P: Magnitude of the linear momentum for each puncture. :type P: float :param parfile: Name of the parameter file to create (default is None, which uses “parfile_P{P:.10f}.par”). :type parfile: str or None, optional :param verbose: If True, print verbose output (default is None, which uses self.verbose). :type verbose: bool or None, optional

Returns:

  • E_ADM (float) – Total ADM energy.

  • M1 (float) – ADM mass of puncture 1.

  • M2 (float) – ADM mass of puncture 2.

run_TP_parallel(momenta, batch)[source]

Run TwoPunctures in parallel for a batch of momenta. :param momenta: Array of momenta to evaluate. :type momenta: array-like :param batch: List of indices in the momenta array to process in this batch. :type batch: list of int

Returns:

energies – Array of computed ADM energies for the given momenta.

Return type:

array-like

fit_iter(P0, dP, npoints=4, poly_order=None, verbose=None, show_plot=False, save_plot=False, x0_position='centered', nproc=1)[source]

Fit a polynomial to find the momentum P that gives the desired energy self.E.

Parameters:
  • P0 (float) – Initial guess for the momentum.

  • dP (float) – Step size for the momentum.

  • npoints (int, optional) – Number of points to evaluate in each iteration (default is 4).

  • poly_order (int or None, optional) – Order of the polynomial fit (default is None, which uses min(max(npoints-1,1),5)).

  • verbose (bool or None, optional) – If True, print verbose output (default is None, which uses self.verbose).

  • show_plot (bool, optional) – If True, show the fit plot (default is False).

  • save_plot (bool, optional) – If True, save the fit plot (default is False).

  • x0_position (str, optional) – Positioning of the points relative to P0: “centered”, “highest”, or “lowest” (default is “centered”).

  • nproc (int, optional) – Number of processors to use for parallel execution (default is 1).

Returns:

Pf – Fitted momentum that gives the desired energy self.E.

Return type:

float

fit_iterations(P0=None, step_rel=0.15, tol=1e-10, resize_factor=100, itermax=5, npoints=4, poly_order=None, verbose=None, nproc=1, save_plot=False, show_plot=False)[source]

Iteratively fit to find the momentum P that gives the desired energy self.E. :param P0: Initial guess for the momentum (default is None, which uses an estimate based on self.E

and self.q).

Parameters:
  • step_rel (float, optional) – Initial relative step size for the momentum (default is 0.15).

  • tol (float, optional) – Tolerance for the relative error in energy (default is 1e-10).

  • resize_factor (float, optional) – Factor to resize the step size in each iteration (default is 100).

  • itermax (int, optional) – Maximum number of iterations (default is 5).

  • npoints (int, optional) – Number of points to evaluate in each iteration (default is 4).

  • poly_order (int or None, optional) – Order of the polynomial fit (default is None, which uses min(max(npoints-1,1),5)).

  • verbose (bool or None, optional) – If True, print verbose output (default is None, which uses self.verbose).

  • nproc (int, optional) – Number of processors to use for parallel execution (default is 1).

  • save_plot (bool, optional) – If True, save the fit plots for each iteration (default is False).

  • show_plot (bool, optional) – If True, show the fit plots for each iteration (default is False).

PyART.numerical.twopuncts_ID.parser[source]