VeraGridEngine.Simulations.EMT.JMARTI_Sim package

Submodules

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_bundle module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_bundle.JMartiFitBundle(frequency_hz: ndarray, line_length_m: float, phase_labels: tuple[str, ...], modal_transform: ndarray, modal_transform_inv: ndarray, reference_frequency_hz: float, decoupling_error_z: ndarray, decoupling_error_y: ndarray, mode_delays: Sequence[JMartiModeDelayEstimate], yc_fits: Sequence[JMartiRationalModeFit], hres_fits: Sequence[JMartiRationalModeFit], passivity_report: JMartiPassivityReport | None)[source]

Bases: object

Aggregated offline JMARTI fitting product ready for runtime conversion.

The fitting pipeline produces modal preprocessing, per-mode delay estimates, per-mode rational fits and optional passivity diagnostics. This object keeps those pieces together under one typed interface before the EMT runtime layer discretizes and consumes them.

get_decoupling_error_y() ndarray[source]

Return the off-diagonal Y decoupling errors.

Returns:

Real-valued Y decoupling error vector.

get_decoupling_error_z() ndarray[source]

Return the off-diagonal Z decoupling errors.

Returns:

Real-valued Z decoupling error vector.

get_frequency_hz() ndarray[source]

Return the fitted frequency grid.

Returns:

Frequency grid in Hz.

get_hres_fits() tuple[JMartiRationalModeFit, ...][source]

Return the scalar Hres fits.

Returns:

Per-mode Hres fit tuple.

get_line_length_m() float[source]

Return the line length in meters.

Returns:

Line length in meters.

get_modal_transform() ndarray[source]

Return the frozen modal transform.

Returns:

Complex modal transform.

get_modal_transform_inv() ndarray[source]

Return the inverse frozen modal transform.

Returns:

Inverse modal transform.

get_mode_count() int[source]

Return the modal order of the fit bundle.

Returns:

Number of modes.

get_mode_delays() tuple[JMartiModeDelayEstimate, ...][source]

Return the modal delay estimates.

Returns:

Per-mode delay tuple.

get_passivity_report() JMartiPassivityReport | None[source]

Return the optional passivity report.

Returns:

Passivity report or None.

get_phase_labels() tuple[str, ...][source]

Return the ordered phase labels.

Returns:

Ordered phase-label tuple.

get_reference_frequency_hz() float[source]

Return the frequency used to freeze the modal basis.

Returns:

Reference frequency in Hz.

get_yc_fits() tuple[JMartiRationalModeFit, ...][source]

Return the scalar Yc fits.

Returns:

Per-mode Yc fit tuple.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_bundle.build_jmarti_fit_bundle(modal_samples: JMartiModalSamples, mode_delays: Sequence[JMartiModeDelayEstimate], yc_fits: Sequence[JMartiRationalModeFit], hres_fits: Sequence[JMartiRationalModeFit], passivity_report: JMartiPassivityReport | None = None) JMartiFitBundle[source]

Build one validated JMARTI fit bundle.

Parameters:
  • modal_samples – Modal preprocessing output.

  • mode_delays – Per-mode delay estimates.

  • yc_fits – Per-mode Yc rational fits.

  • hres_fits – Per-mode Hres rational fits.

  • passivity_report – Optional passivity report.

Returns:

Validated fit bundle.

Raises:

ValueError – If the per-mode objects do not align.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_options module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_options.JMartiFitOptions(reference_frequency_hz: float = 0.0, use_frequency_exploration_window: bool = False, exploration_low_hz: float = 0.0, exploration_high_hz: float = 0.0, use_delay_fit_window: bool = False, delay_fit_low_hz: float = 0.0, delay_fit_high_hz: float = 0.0, decoupling_warning_tolerance: float = 0.01, loewner_relative_tolerance: float = 1e-08, maximum_model_order: int = 40, forced_model_order: int = 0, minimum_frequency_samples: int = 4, vf_max_iterations: int = 8, vf_pole_shift_tolerance: float = 1e-06, vf_enforce_stable_poles: bool = True, vf_stability_real_part_floor: float = 1e-08, vf_include_constant_term: bool = True, vf_include_proportional_term: bool = False, passivity_frequency_sample_count: int = 1024, passivity_minimum_real_yc_tolerance: float = 1e-08, passivity_maximum_hres_gain_tolerance: float = 1e-06)[source]

Bases: OptionsTemplate

User-configurable numerical options for the JMARTI fitting workflow.

The fitting stages must remain externally configurable because real line data sets vary strongly in frequency span, modal coupling, and required rational order. The object centralizes all public knobs used by the current offline preprocessing stages.

CLASS_NON_EDITABLE_PROPERTIES: Tuple[str, ...] = ('idtag', 'diff_changes')
CLASS_PROPERTIES_WITH_PROFILE: Dict[str, str] = {}
CLASS_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:reference_frequency_hz, prop:use_frequency_exploration_window, prop:exploration_low_hz, prop:exploration_high_hz, prop:use_delay_fit_window, prop:delay_fit_low_hz, prop:delay_fit_high_hz, prop:decoupling_warning_tolerance, prop:loewner_relative_tolerance, prop:maximum_model_order, prop:forced_model_order, prop:minimum_frequency_samples, prop:vf_max_iterations, prop:vf_pole_shift_tolerance, prop:vf_enforce_stable_poles, prop:vf_stability_real_part_floor, prop:vf_include_constant_term, prop:vf_include_proportional_term, prop:passivity_frequency_sample_count, prop:passivity_minimum_real_yc_tolerance, prop:passivity_maximum_hres_gain_tolerance)
CLASS_PROPERTY_LIST: Tuple[GCProp, ...] = (prop:idtag, prop:name, prop:code, prop:rdfid, prop:action, prop:comment, prop:diff_changes, prop:reference_frequency_hz, prop:use_frequency_exploration_window, prop:exploration_low_hz, prop:exploration_high_hz, prop:use_delay_fit_window, prop:delay_fit_low_hz, prop:delay_fit_high_hz, prop:decoupling_warning_tolerance, prop:loewner_relative_tolerance, prop:maximum_model_order, prop:forced_model_order, prop:minimum_frequency_samples, prop:vf_max_iterations, prop:vf_pole_shift_tolerance, prop:vf_enforce_stable_poles, prop:vf_stability_real_part_floor, prop:vf_include_constant_term, prop:vf_include_proportional_term, prop:passivity_frequency_sample_count, prop:passivity_minimum_real_yc_tolerance, prop:passivity_maximum_hres_gain_tolerance)
CLASS_REGISTERED_PROPERTIES: Dict[str, GCProp] = {'action': prop:action, 'code': prop:code, 'comment': prop:comment, 'decoupling_warning_tolerance': prop:decoupling_warning_tolerance, 'delay_fit_high_hz': prop:delay_fit_high_hz, 'delay_fit_low_hz': prop:delay_fit_low_hz, 'diff_changes': prop:diff_changes, 'exploration_high_hz': prop:exploration_high_hz, 'exploration_low_hz': prop:exploration_low_hz, 'forced_model_order': prop:forced_model_order, 'idtag': prop:idtag, 'loewner_relative_tolerance': prop:loewner_relative_tolerance, 'maximum_model_order': prop:maximum_model_order, 'minimum_frequency_samples': prop:minimum_frequency_samples, 'name': prop:name, 'passivity_frequency_sample_count': prop:passivity_frequency_sample_count, 'passivity_maximum_hres_gain_tolerance': prop:passivity_maximum_hres_gain_tolerance, 'passivity_minimum_real_yc_tolerance': prop:passivity_minimum_real_yc_tolerance, 'rdfid': prop:rdfid, 'reference_frequency_hz': prop:reference_frequency_hz, 'use_delay_fit_window': prop:use_delay_fit_window, 'use_frequency_exploration_window': prop:use_frequency_exploration_window, 'vf_enforce_stable_poles': prop:vf_enforce_stable_poles, 'vf_include_constant_term': prop:vf_include_constant_term, 'vf_include_proportional_term': prop:vf_include_proportional_term, 'vf_max_iterations': prop:vf_max_iterations, 'vf_pole_shift_tolerance': prop:vf_pole_shift_tolerance, 'vf_stability_real_part_floor': prop:vf_stability_real_part_floor}
LOCAL_PROPERTY_DECLARATIONS: Tuple[GCProp, ...] = (prop:reference_frequency_hz, prop:use_frequency_exploration_window, prop:exploration_low_hz, prop:exploration_high_hz, prop:use_delay_fit_window, prop:delay_fit_low_hz, prop:delay_fit_high_hz, prop:decoupling_warning_tolerance, prop:loewner_relative_tolerance, prop:maximum_model_order, prop:forced_model_order, prop:minimum_frequency_samples, prop:vf_max_iterations, prop:vf_pole_shift_tolerance, prop:vf_enforce_stable_poles, prop:vf_stability_real_part_floor, prop:vf_include_constant_term, prop:vf_include_proportional_term, prop:passivity_frequency_sample_count, prop:passivity_minimum_real_yc_tolerance, prop:passivity_maximum_hres_gain_tolerance)
property decoupling_warning_tolerance: float

Property wrapper for the modal decoupling tolerance.

Returns:

Non-negative error tolerance.

property delay_fit_high_hz: float

Property wrapper for the upper delay-fit edge.

Returns:

Upper edge in Hz.

property delay_fit_low_hz: float

Property wrapper for the lower delay-fit edge.

Returns:

Lower edge in Hz.

property exploration_high_hz: float

Property wrapper for the upper fitting-band edge.

Returns:

Upper edge in Hz.

property exploration_low_hz: float

Property wrapper for the lower fitting-band edge.

Returns:

Lower edge in Hz.

property forced_model_order: int

Property wrapper for the forced model order.

Returns:

Forced order, or 0 when automatic.

get_decoupling_warning_tolerance() float[source]

Return the maximum acceptable modal decoupling error.

Returns:

Non-negative error tolerance.

get_delay_fit_high_hz() float[source]

Return the upper edge of the delay-fit band.

Returns:

Upper edge in Hz.

get_delay_fit_low_hz() float[source]

Return the lower edge of the delay-fit band.

Returns:

Lower edge in Hz.

get_exploration_high_hz() float[source]

Return the upper edge of the fitting band.

Returns:

Upper edge in Hz.

get_exploration_low_hz() float[source]

Return the lower edge of the fitting band.

Returns:

Lower edge in Hz.

get_forced_model_order() int[source]

Return the user-forced rational order.

Returns:

Forced order, or 0 when order estimation remains automatic.

get_loewner_relative_tolerance() float[source]

Return the relative Loewner singular-value tolerance.

Returns:

Positive relative tolerance.

get_maximum_model_order() int[source]

Return the maximum rational order allowed by the user.

Returns:

Positive order cap.

get_minimum_frequency_samples() int[source]

Return the minimum number of frequency samples required.

Returns:

Minimum sample count.

get_passivity_frequency_sample_count() int[source]

Return the dense frequency-grid size used for passivity checks.

Returns:

Positive sample count.

get_passivity_maximum_hres_gain_tolerance() float[source]

Return the allowed gain slack above unity for |Hres(jw)|.

Returns:

Non-negative tolerance.

get_passivity_minimum_real_yc_tolerance() float[source]

Return the allowed negativity slack for Re(Yc(jw)).

Returns:

Non-negative tolerance.

get_reference_frequency_hz() float[source]

Return the reference frequency used to freeze the modal basis.

Returns:

Reference frequency in Hz. 0.0 means automatic.

get_use_delay_fit_window() bool[source]

Return whether the delay-fit band restriction is enabled.

Returns:

Boolean state.

get_use_frequency_exploration_window() bool[source]

Return whether the fitting band restriction is enabled.

Returns:

Boolean state.

get_vf_enforce_stable_poles() bool[source]

Return whether unstable poles must be reflected into the left half-plane.

Returns:

Boolean state.

get_vf_include_constant_term() bool[source]

Return whether the rational fit includes one constant term.

Returns:

Boolean state.

get_vf_include_proportional_term() bool[source]

Return whether the rational fit includes one proportional s term.

Returns:

Boolean state.

get_vf_max_iterations() int[source]

Return the maximum number of Vector Fitting relocation iterations.

Returns:

Positive iteration cap.

get_vf_pole_shift_tolerance() float[source]

Return the Vector Fitting pole-shift stopping tolerance.

Returns:

Positive relative tolerance.

get_vf_stability_real_part_floor() float[source]

Return the minimum absolute negative real part used after pole reflection.

Returns:

Positive floor value.

property loewner_relative_tolerance: float

Property wrapper for the Loewner singular-value tolerance.

Returns:

Positive relative tolerance.

property maximum_model_order: int

Property wrapper for the maximum model order.

Returns:

Positive order cap.

property minimum_frequency_samples: int

Property wrapper for the minimum sample count.

Returns:

Minimum sample count.

property passivity_frequency_sample_count: int

Property wrapper for the passivity frequency-grid size.

Returns:

Positive sample count.

property passivity_maximum_hres_gain_tolerance: float

Property wrapper for the |Hres| gain slack tolerance.

Returns:

Non-negative tolerance.

property passivity_minimum_real_yc_tolerance: float

Property wrapper for the Re(Yc) negativity tolerance.

Returns:

Non-negative tolerance.

property reference_frequency_hz: float

Property wrapper for the reference frequency.

Returns:

Reference frequency in Hz.

set_decoupling_warning_tolerance(value: float) None[source]

Set the maximum acceptable modal decoupling error.

Parameters:

value – Requested non-negative tolerance.

Returns:

None.

set_delay_fit_high_hz(value: float) None[source]

Set the upper edge of the delay-fit band.

Parameters:

value – Requested upper edge in Hz.

Returns:

None.

set_delay_fit_low_hz(value: float) None[source]

Set the lower edge of the delay-fit band.

Parameters:

value – Requested lower edge in Hz.

Returns:

None.

set_exploration_high_hz(value: float) None[source]

Set the upper edge of the fitting band.

Parameters:

value – Requested upper edge in Hz.

Returns:

None.

set_exploration_low_hz(value: float) None[source]

Set the lower edge of the fitting band.

Parameters:

value – Requested lower edge in Hz.

Returns:

None.

set_forced_model_order(value: int) None[source]

Set the user-forced rational order.

Parameters:

value – Requested order. 0 keeps automatic order estimation.

Returns:

None.

set_loewner_relative_tolerance(value: float) None[source]

Set the relative Loewner singular-value tolerance.

Parameters:

value – Requested positive tolerance.

Returns:

None.

set_maximum_model_order(value: int) None[source]

Set the maximum rational order allowed by the user.

Parameters:

value – Requested positive order cap.

Returns:

None.

set_minimum_frequency_samples(value: int) None[source]

Set the minimum number of frequency samples required.

Parameters:

value – Requested minimum sample count.

Returns:

None.

set_passivity_frequency_sample_count(value: int) None[source]

Set the dense frequency-grid size used for passivity checks.

Parameters:

value – Requested positive sample count.

Returns:

None.

set_passivity_maximum_hres_gain_tolerance(value: float) None[source]

Set the allowed gain slack above unity for |Hres(jw)|.

Parameters:

value – Requested non-negative tolerance.

Returns:

None.

set_passivity_minimum_real_yc_tolerance(value: float) None[source]

Set the allowed negativity slack for Re(Yc(jw)).

Parameters:

value – Requested non-negative tolerance.

Returns:

None.

set_reference_frequency_hz(value: float) None[source]

Set the reference frequency used to freeze the modal basis.

Parameters:

value – Requested reference frequency in Hz.

Returns:

None.

set_use_delay_fit_window(value: bool) None[source]

Enable or disable the delay-fit band restriction.

Parameters:

value – Requested boolean state.

Returns:

None.

set_use_frequency_exploration_window(value: bool) None[source]

Enable or disable the fitting band restriction.

Parameters:

value – Requested boolean state.

Returns:

None.

set_vf_enforce_stable_poles(value: bool) None[source]

Enable or disable pole reflection into the left half-plane.

Parameters:

value – Requested boolean state.

Returns:

None.

set_vf_include_constant_term(value: bool) None[source]

Enable or disable the constant term in the rational fit.

Parameters:

value – Requested boolean state.

Returns:

None.

set_vf_include_proportional_term(value: bool) None[source]

Enable or disable the proportional s term in the rational fit.

Parameters:

value – Requested boolean state.

Returns:

None.

set_vf_max_iterations(value: int) None[source]

Set the maximum number of Vector Fitting relocation iterations.

Parameters:

value – Requested positive iteration cap.

Returns:

None.

set_vf_pole_shift_tolerance(value: float) None[source]

Set the Vector Fitting pole-shift stopping tolerance.

Parameters:

value – Requested positive relative tolerance.

Returns:

None.

set_vf_stability_real_part_floor(value: float) None[source]

Set the minimum absolute negative real part used after pole reflection.

Parameters:

value – Requested positive floor value.

Returns:

None.

property use_delay_fit_window: bool

Property wrapper for the delay-fit band restriction flag.

Returns:

Boolean state.

property use_frequency_exploration_window: bool

Property wrapper for the fitting band restriction flag.

Returns:

Boolean state.

property vf_enforce_stable_poles: bool

Property wrapper for the stable-pole enforcement flag.

Returns:

Boolean state.

property vf_include_constant_term: bool

Property wrapper for the constant-term flag.

Returns:

Boolean state.

property vf_include_proportional_term: bool

Property wrapper for the proportional-term flag.

Returns:

Boolean state.

property vf_max_iterations: int

Property wrapper for the Vector Fitting iteration cap.

Returns:

Positive iteration cap.

property vf_pole_shift_tolerance: float

Property wrapper for the Vector Fitting pole-shift tolerance.

Returns:

Positive relative tolerance.

property vf_stability_real_part_floor: float

Property wrapper for the reflected-pole real-part floor.

Returns:

Positive floor value.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_workflow module

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_workflow.build_jmarti_fit_bundle_from_frequency_samples(samples: JMartiFrequencySamples, options: JMartiFitOptions | None = None) JMartiFitBundle[source]

Run the full first-generation JMARTI fitting pipeline on one sample set.

The helper centralizes the modal preprocessing, delay extraction, Loewner seeding, Vector Fitting, and passivity-like checks so higher layers such as the GUI can trigger one consistent offline preprocessing workflow.

Parameters:
  • samples – Frequency-domain line dataset.

  • options – Optional user-configurable fit options.

Returns:

Offline JMARTI fit bundle.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_workflow.build_jmarti_frequency_grid(low_hz: float, high_hz: float, sample_count: int) ndarray[source]

Build one monotone frequency grid for one JMARTI preprocessing run.

The GUI-driven fitting flow lets the user configure the exploration band and the number of samples used to interrogate the line model. Positive lower limits use logarithmic spacing, while bands starting at zero fall back to an affine grid.

Parameters:
  • low_hz – Lower frequency bound in Hz.

  • high_hz – Upper frequency bound in Hz.

  • sample_count – Number of requested samples.

Returns:

Frequency vector in Hz.

Raises:

ValueError – If the requested band is invalid.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_workflow.build_jmarti_frequency_samples_from_line(line: Line, phase_n: bool, phase_a: bool, phase_b: bool, phase_c: bool, low_hz: float, high_hz: float, sample_count: int, nominal_frequency_hz: float | None = None, sbase_mva: float | None = None) JMartiFrequencySamples[source]

Build one JMARTI frequency-domain dataset from one physical line object.

The GUI-driven flow targets concrete Line devices backed by one overhead, sequence, or underground template. When the template still carries conductor geometry, the sweep is evaluated directly over frequency. Otherwise the first implementation falls back to one frequency-independent RLGC extrapolation reconstructed from the nominal template values.

Parameters:
  • line – Concrete line device being edited.

  • phase_n – Whether the neutral is enabled on the EMT block.

  • phase_a – Whether phase A is enabled.

  • phase_b – Whether phase B is enabled.

  • phase_c – Whether phase C is enabled.

  • low_hz – Lower sweep frequency in Hz.

  • high_hz – Upper sweep frequency in Hz.

  • sample_count – Number of sweep samples.

  • nominal_frequency_hz – Optional nominal frequency used to reconstruct RLGC sweeps.

  • sbase_mva – System base power in MVA used to convert the line data to per unit.

Returns:

Frequency-domain JMARTI sample set.

Raises:

ValueError – If the line cannot provide compatible data.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_workflow.build_jmarti_hres_modal_responses(modal_samples: JMartiModalSamples, mode_delays: Sequence[JMartiModeDelayEstimate]) ndarray[source]

Build the residual propagation responses fitted as Hres per mode.

Hres is the propagation operator left after extracting one pure delay from each modal channel. It combines attenuation and the residual dispersive phase not captured by the affine delay estimate.

Parameters:
  • modal_samples – Modalized frequency samples.

  • mode_delays – Per-mode delay estimates.

Returns:

Complex response matrix with shape (nf, nmodes).

Raises:

ValueError – If the modal objects do not align.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_fit_workflow.load_jmarti_frequency_samples_from_npz(file_path: str, phase_n: bool, phase_a: bool, phase_b: bool, phase_c: bool, fallback_line_length_m: float | None = None) JMartiFrequencySamples[source]

Load one JMARTI frequency-domain sample set from one NPZ archive.

Required arrays: - frequency_hz with shape (nf,) - z_per_length or z_per_length_real/z_per_length_imag with shape (nf, np, np) - y_per_length or y_per_length_real/y_per_length_imag with shape (nf, np, np)

Optional arrays: - phase_labels with shape (np,) - line_length_m scalar

Unit convention: - z_per_length must already be expressed in per-unit per meter - y_per_length must already be expressed in per-unit per meter

Parameters:
  • file_path – NPZ file path.

  • phase_n – Whether the neutral is enabled.

  • phase_a – Whether phase A is enabled.

  • phase_b – Whether phase B is enabled.

  • phase_c – Whether phase C is enabled.

  • fallback_line_length_m – Optional line-length fallback in meters.

Returns:

Imported and validated frequency-domain samples.

Raises:

ValueError – If the archive is missing required data.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_frequency_samples module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_frequency_samples.JMartiFrequencySamples(frequency_hz: Sequence[float], z_per_length: ndarray, y_per_length: ndarray, line_length_m: float, phase_labels: Sequence[str])[source]

Bases: object

Typed container holding frequency-domain line samples for one JMARTI fit.

The fitting workflow starts from sampled multiconductor series impedance and shunt admittance matrices. The container validates all structural assumptions once so every later fitting stage can rely on a coherent input.

get_angular_frequency_rad_per_s() ndarray[source]

Return the sampled angular-frequency vector.

Returns:

Angular-frequency vector in rad/s.

get_frequency_count() int[source]

Return the number of sampled frequencies.

Returns:

Number of frequency samples.

get_frequency_hz() ndarray[source]

Return the sampled frequency vector.

Returns:

Frequency vector in Hz.

get_line_length_m() float[source]

Return the physical line length in meters.

Returns:

Line length in meters.

get_phase_count() int[source]

Return the number of conductors or phases in the sample set.

Returns:

Matrix dimension.

get_phase_labels() tuple[str, ...][source]

Return the ordered phase labels.

Returns:

Ordered phase-label tuple.

get_y_per_length() ndarray[source]

Return the sampled shunt admittance matrices.

Returns:

Complex admittance tensor with shape (nf, np, np).

get_z_per_length() ndarray[source]

Return the sampled series impedance matrices.

Returns:

Complex impedance tensor with shape (nf, np, np).

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_frequency_samples.build_jmarti_frequency_samples(frequency_hz: Sequence[float], z_per_length: ndarray, y_per_length: ndarray, line_length_m: float, phase_labels: Sequence[str]) JMartiFrequencySamples[source]

Build one validated JMARTI frequency-sample container.

Parameters:
  • frequency_hz – Strictly increasing frequency samples in Hz.

  • z_per_length – Series impedance matrices with shape (nf, np, np).

  • y_per_length – Shunt admittance matrices with shape (nf, np, np).

  • line_length_m – Physical line length in meters.

  • phase_labels – Ordered phase labels associated with the matrices.

Returns:

Validated frequency-sample container.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_frequency_samples.build_jmarti_frequency_subset(samples: JMartiFrequencySamples, low_hz: float, high_hz: float) JMartiFrequencySamples[source]

Build one frequency-window subset of a JMARTI sample set.

Parameters:
  • samples – Full sample set.

  • low_hz – Lower retained frequency in Hz.

  • high_hz – Upper retained frequency in Hz.

Returns:

Windowed sample set.

Raises:

ValueError – If the requested window leaves too few samples.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_frequency_samples.validate_jmarti_frequency_samples(samples: JMartiFrequencySamples) None[source]

Validate one JMARTI frequency-sample container.

Parameters:

samples – Frequency-sample container to validate.

Returns:

None.

Raises:

ValueError – If the sample set is structurally inconsistent.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed.JMartiModeLoewnerSeed(mode_index: int, target_name: str, left_frequencies_hz: ndarray, right_frequencies_hz: ndarray, singular_values: ndarray, estimated_order: int, initial_poles_s: ndarray, truncation_ratio: float)[source]

Bases: object

Loewner-based order and pole seed for one scalar JMARTI modal target.

The class stores the reduced-order information that later feeds the Vector Fitting stage. The seed is intentionally scalar per mode because the first JMARTI implementation in VeraGrid fits each modal channel independently.

get_estimated_order() int[source]

Return the estimated reduced order.

Returns:

Reduced order.

get_initial_poles_s() ndarray[source]

Return the initial continuous-time poles.

Returns:

Complex pole vector.

get_left_frequencies_hz() ndarray[source]

Return the left frequency subset.

Returns:

Left sample frequencies in Hz.

get_mode_index() int[source]

Return the modal channel index.

Returns:

Modal channel index.

get_right_frequencies_hz() ndarray[source]

Return the right frequency subset.

Returns:

Right sample frequencies in Hz.

get_singular_values() ndarray[source]

Return the singular values of the Loewner matrix.

Returns:

Singular-value vector.

get_target_name() str[source]

Return the scalar target name.

Returns:

Target name.

get_truncation_ratio() float[source]

Return the first discarded-to-leading singular-value ratio.

Returns:

Truncation ratio.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed.build_jmarti_loewner_left_right_partition(frequency_hz: ndarray, response_values: ndarray, minimum_frequency_samples: int) Tuple[ndarray, ndarray, ndarray, ndarray][source]

Split one scalar frequency response into interleaved left and right subsets.

The Loewner framework requires two disjoint sampling sets. Interleaving the original frequency grid preserves broad-band coverage on both sides without introducing user-tuned partition heuristics in the first implementation.

Parameters:
  • frequency_hz – Strictly increasing frequency samples in Hz.

  • response_values – Complex scalar response samples on the same grid.

  • minimum_frequency_samples – Minimum number of total samples required by the user options.

Returns:

Tuple (left_f_hz, right_f_hz, left_resp, right_resp).

Raises:

ValueError – If the sample vectors are too short or inconsistent.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed.build_jmarti_loewner_matrices(left_frequencies_hz: ndarray, right_frequencies_hz: ndarray, left_response: ndarray, right_response: ndarray) Tuple[ndarray, ndarray][source]

Build the Loewner and shifted-Loewner matrices for one scalar response.

Parameters:
  • left_frequencies_hz – Left frequency subset in Hz.

  • right_frequencies_hz – Right frequency subset in Hz.

  • left_response – Complex response samples on the left subset.

  • right_response – Complex response samples on the right subset.

Returns:

Tuple (L, Ls).

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed.build_jmarti_mode_loewner_seed(frequency_hz: Sequence[float], response_values: ndarray, target_name: str, mode_index: int, options: JMartiFitOptions | None = None) JMartiModeLoewnerSeed[source]

Build one Loewner seed bundle for a scalar JMARTI modal target.

Parameters:
  • frequency_hz – Strictly increasing frequency grid in Hz.

  • response_values – Complex scalar response samples on that grid.

  • target_name – Modal target name, for example Yc or Hres.

  • mode_index – Modal channel index.

  • options – Optional user-configurable JMARTI fitting options.

Returns:

Loewner seed bundle.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed.estimate_jmarti_loewner_order(singular_values: ndarray, relative_tolerance: float, maximum_order: int, forced_model_order: int) Tuple[int, float][source]

Estimate one reduced order from Loewner singular values.

Parameters:
  • singular_values – Singular-value vector in descending order.

  • relative_tolerance – Relative truncation tolerance.

  • maximum_order – Optional maximum order clamp.

  • forced_model_order – Fixed user order. 0 means automatic.

Returns:

Tuple (estimated_order, truncation_ratio).

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_loewner_seed.extract_jmarti_loewner_initial_poles(loewner_matrix: ndarray, shifted_loewner_matrix: ndarray, estimated_order: int) ndarray[source]

Extract one set of continuous-time poles from the reduced Loewner pencil.

Parameters:
  • loewner_matrix – Loewner matrix.

  • shifted_loewner_matrix – Shifted Loewner matrix.

  • estimated_order – Reduced order used for projection.

Returns:

Complex initial pole vector.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_modal_processing module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_modal_processing.JMartiModalSamples(frequency_hz: ndarray, line_length_m: float, phase_labels: tuple[str, ...], modal_transform: ndarray, modal_transform_inv: ndarray, z_modal: ndarray, y_modal: ndarray, z_modal_diag: ndarray, y_modal_diag: ndarray, gamma_modal: ndarray, yc_modal: ndarray, decoupling_error_z: ndarray, decoupling_error_y: ndarray, reference_frequency_hz: float)[source]

Bases: object

Modalized JMARTI frequency samples built from one constant modal transform.

The first JMARTI implementation in VeraGrid assumes an approximately constant modal basis over the fitted band. The object stores that common basis and all diagonal modal quantities derived from it.

get_angular_frequency_rad_per_s() ndarray[source]

Return the modal angular-frequency grid.

Returns:

Angular-frequency grid in rad/s.

get_decoupling_error_y() ndarray[source]

Return the off-diagonal Y decoupling errors.

Returns:

Real-valued error vector over frequency.

get_decoupling_error_z() ndarray[source]

Return the off-diagonal Z decoupling errors.

Returns:

Real-valued error vector over frequency.

get_frequency_hz() ndarray[source]

Return the modal frequency grid.

Returns:

Frequency grid in Hz.

get_gamma_modal() ndarray[source]

Return the modal propagation constants per unit length.

Returns:

Complex modal propagation constants.

get_line_length_m() float[source]

Return the line length in meters.

Returns:

Line length in meters.

get_modal_transform() ndarray[source]

Return the common modal transform.

Returns:

Complex modal transform.

get_modal_transform_inv() ndarray[source]

Return the inverse common modal transform.

Returns:

Inverse modal transform.

get_mode_count() int[source]

Return the number of fitted modes.

Returns:

Mode count.

get_phase_labels() tuple[str, ...][source]

Return the ordered phase labels.

Returns:

Ordered phase-label tuple.

get_reference_frequency_hz() float[source]

Return the frequency used to freeze the modal basis.

Returns:

Reference frequency in Hz.

get_y_modal() ndarray[source]

Return projected modal shunt-admittance matrices.

Returns:

Complex modal admittance tensor.

get_y_modal_diag() ndarray[source]

Return the diagonal modal admittance samples.

Returns:

Complex diagonal modal admittance array.

get_yc_modal() ndarray[source]

Return the modal characteristic admittances.

Returns:

Complex modal characteristic-admittance array.

get_z_modal() ndarray[source]

Return projected modal series-impedance matrices.

Returns:

Complex modal impedance tensor.

get_z_modal_diag() ndarray[source]

Return the diagonal modal impedance samples.

Returns:

Complex diagonal modal impedance array.

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_modal_processing.JMartiModeDelayEstimate(mode_index: int, tau_s: float, rms_phase_error_rad: float)[source]

Bases: object

Delay estimate of one modal propagation channel.

get_mode_index() int[source]

Return the modal channel index.

Returns:

Modal channel index.

get_rms_phase_error_rad() float[source]

Return the RMS residual of the affine phase fit.

Returns:

RMS residual in radians.

get_tau_s() float[source]

Return the estimated delay in seconds.

Returns:

Delay in seconds.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_modal_processing.build_jmarti_modal_samples(samples: JMartiFrequencySamples, options: JMartiFitOptions | None = None) JMartiModalSamples[source]

Build modal JMARTI samples from one frequency-domain line dataset.

The first JMARTI implementation freezes one common modal basis at a single reference frequency and reuses it across the whole fitted band. This is the standard pragmatic starting point before moving to a fully frequency-varying modal transform.

Parameters:
  • samples – Frequency-domain line dataset.

  • options – Optional user-configurable JMARTI fitting options.

Returns:

Modalized sample set.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_modal_processing.estimate_jmarti_mode_delays(modal_samples: JMartiModalSamples, options: JMartiFitOptions | None = None) list[JMartiModeDelayEstimate][source]

Estimate one pure propagation delay for each JMARTI mode.

The pure delay is extracted from the modal propagation phase beta(omega) * length through one affine fit in angular frequency. The residual phase error indicates how much non-ideal frequency dispersion is left for the rational residual propagation fit.

Parameters:
  • modal_samples – Modalized JMARTI sample set.

  • options – Optional user-configurable JMARTI fitting options.

Returns:

Delay estimates for every modal channel.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_passivity module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_passivity.JMartiModePassivityReport(mode_index: int, target_name: str, minimum_real_part: float, maximum_gain: float, minimum_real_frequency_hz: float, maximum_gain_frequency_hz: float, passes_real_part_check: bool, passes_gain_check: bool)[source]

Bases: object

Passivity-like and boundedness metrics for one scalar JMARTI mode.

The first JMARTI implementation treats the modal channels independently. For that reason the physical admissibility checks are also scalar per mode: Re(Yc) must remain non-negative within tolerance and |Hres| must not exceed one beyond the configured slack.

get_maximum_gain() float[source]

Return the maximum sampled magnitude.

Returns:

Maximum sampled magnitude.

get_maximum_gain_frequency_hz() float[source]

Return the frequency where the maximum magnitude occurs.

Returns:

Frequency in Hz.

get_minimum_real_frequency_hz() float[source]

Return the frequency where the minimum real part occurs.

Returns:

Frequency in Hz.

get_minimum_real_part() float[source]

Return the minimum sampled real part.

Returns:

Minimum sampled real part.

get_mode_index() int[source]

Return the modal channel index.

Returns:

Modal channel index.

get_passes_gain_check() bool[source]

Return whether the gain admissibility test passes.

Returns:

Boolean state.

get_passes_real_part_check() bool[source]

Return whether the real-part admissibility test passes.

Returns:

Boolean state.

get_target_name() str[source]

Return the scalar target name.

Returns:

Scalar target name.

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_passivity.JMartiPassivityReport(frequency_hz: ndarray, mode_reports: Sequence[JMartiModePassivityReport])[source]

Bases: object

Aggregate passivity-like report for a set of scalar JMARTI fits.

get_all_checks_pass() bool[source]

Return whether every mode passes its admissibility checks.

Returns:

Boolean global status.

get_frequency_hz() ndarray[source]

Return the dense frequency grid used for the checks.

Returns:

Dense frequency grid in Hz.

get_mode_reports() tuple[JMartiModePassivityReport, ...][source]

Return the per-mode reports.

Returns:

Per-mode report tuple.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_passivity.build_jmarti_passivity_frequency_grid(low_hz: float, high_hz: float, sample_count: int) ndarray[source]

Build one dense frequency grid for passivity checks.

Parameters:
  • low_hz – Lower frequency in Hz.

  • high_hz – Upper frequency in Hz.

  • sample_count – Number of samples requested by the user.

Returns:

Dense logarithmic or affine frequency grid.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_passivity.evaluate_jmarti_mode_passivity(fit: JMartiRationalModeFit, frequency_hz: Sequence[float], options: JMartiFitOptions | None = None) JMartiModePassivityReport[source]

Evaluate one scalar JMARTI mode on a dense frequency grid.

Yc is checked through its minimum real part, while propagation-like targets such as Hres are checked through their maximum gain.

Parameters:
  • fit – Scalar rational fit.

  • frequency_hz – Dense frequency grid in Hz.

  • options – Optional user-configurable JMARTI fitting options.

Returns:

Scalar passivity/boundedness report.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_passivity.evaluate_jmarti_passivity_report(fits: Sequence[JMartiRationalModeFit], low_hz: float, high_hz: float, options: JMartiFitOptions | None = None) JMartiPassivityReport[source]

Evaluate passivity-like metrics for a set of scalar JMARTI fits.

Parameters:
  • fits – Scalar rational fits to inspect.

  • low_hz – Lower frequency of the dense check grid.

  • high_hz – Upper frequency of the dense check grid.

  • options – Optional user-configurable JMARTI fitting options.

Returns:

Aggregate passivity report.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime.JMartiHistoryRuntime(line: Any, line_block: Block, h: float)[source]

Bases: object

Runtime companion for a JMARTI line in reduced active-phase space.

The first implementation uses a constant modal basis and one scalar fit per mode. The runtime keeps all convolution-like states internally and exposes only phase-domain Norton history current injections back to the EMT solver.

Ih_f: List[Var]
Ih_t: List[Var]
active_ph: List[str]
bind_terminals(v_f_vars: List[Any], v_t_vars: List[Any]) None[source]

Bind the bus terminal voltage variables for the active phases only.

Parameters:
  • v_f_vars – Full from-side bus voltage variable list in NABC order.

  • v_t_vars – Full to-side bus voltage variable list in NABC order.

Returns:

None.

block
buf_a_f: ndarray
buf_a_t: ndarray
buffer_size: int
direct_yc_modal: ndarray
direct_yc_phase: ndarray
direct_zc_modal: ndarray
get_mode_count() int[source]

Return the number of modal channels carried by the runtime.

Returns:

Number of modal channels.

get_nodal_injections() Tuple[List[Any], List[Any]][source]

Return the phase-domain Norton injections seen by the EMT nodal solver.

Returns:

Tuple (i_from_full, i_to_full) in fixed NABC order.

h
hres_order_counts: ndarray
hres_state_from: ndarray
hres_state_to: ndarray
idx_p_hf
idx_p_ht
idx_vf
idx_vt
initialize_from_fundamental_phasors(v_f0_phasor_red: ndarray, v_t0_phasor_red: ndarray, i_f0_phasor_red: ndarray, i_t0_phasor_red: ndarray, system_frequency_hz: float) tuple[ndarray, ndarray][source]

Initialize one JMARTI runtime from one sinusoidal fundamental operating point.

The runtime states represent first-order discrete filters, so their consistent steady state under a balanced sinusoidal operating point is not the constant-input equilibrium. This initializer seeds the internal modal states with the periodic discrete-time solution at the requested fundamental frequency.

Parameters:
  • v_f0_phasor_red – From-side phase phasors in RMS complex form.

  • v_t0_phasor_red – To-side phase phasors in RMS complex form.

  • i_f0_phasor_red – From-side branch-current phasors in RMS complex form.

  • i_t0_phasor_red – To-side branch-current phasors in RMS complex form.

  • system_frequency_hz – Fundamental system frequency in Hz.

Returns:

Tuple (ih_f_phase, ih_t_phase) used to seed event parameters.

initialize_from_initial_point(v_f0_red: ndarray, v_t0_red: ndarray, i_f0_red: ndarray, i_t0_red: ndarray) tuple[ndarray, ndarray][source]

Initialize buffers and history parameters from one steady-state point.

Parameters:
  • v_f0_red – From-side active-phase voltages in phase coordinates.

  • v_t0_red – To-side active-phase voltages in phase coordinates.

  • i_f0_red – From-side active-phase currents in phase coordinates.

  • i_t0_red – To-side active-phase currents in phase coordinates.

Returns:

Tuple (ih_f_phase, ih_t_phase) used to seed event parameters.

line
m: int
max_delay_steps: int
ph_labels: List[str]
ph_mask: ndarray
phase_idx: List[int]
runtime_data
setup_indices(uid2idx_vars: dict, uid2idx_event_params: dict, params_offset: int = 0) None[source]

Bind solver indices used during the history update.

Parameters:
  • uid2idx_vars – Variable index map.

  • uid2idx_event_params – Event-parameter index map.

  • params_offset – Runtime-parameter offset.

Returns:

None.

update_history(step_counter: int, x_prev: ndarray, full_params: ndarray) None[source]

Update the retained JMARTI history injections after one accepted EMT step.

Parameters:
  • step_counter – Current accepted step counter.

  • x_prev – Previous accepted state vector.

  • full_params – Flat runtime parameter vector.

Returns:

None.

v_f_vars
v_t_vars
yc_order_counts: ndarray
yc_state_from: ndarray
yc_state_to: ndarray
VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime.get_jmarti_block_fit_bundle(block: Block | None) JMartiFitBundle | None[source]

Return the optional JMARTI fit bundle attached to one EMT block.

Parameters:

block – Candidate EMT block.

Returns:

Attached fit bundle or None.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime.get_jmarti_block_runtime_data(block: Block | None) JMartiRuntimeData | None[source]

Return the optional JMARTI runtime data attached to one EMT block.

Parameters:

block – Candidate EMT block.

Returns:

Attached runtime data or None.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime.set_jmarti_block_fit_bundle(block: Block, fit_bundle: JMartiFitBundle | None) None[source]

Attach one optional JMARTI fit bundle to one EMT block.

Parameters:
  • block – Target EMT block.

  • fit_bundle – Optional offline fit bundle.

Returns:

None.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime.set_jmarti_block_runtime_data(block: Block, runtime_data: JMartiRuntimeData | None) None[source]

Attach one optional discretized JMARTI runtime data object to one EMT block.

Parameters:
  • block – Target EMT block.

  • runtime_data – Optional runtime data.

Returns:

None.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime_data module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime_data.JMartiModeRuntimeData(mode_index: int, tau_s: float, delay_step_count: int, residual_delay_s: float, yc_poles_s: ndarray, yc_residues: ndarray, yc_constant_term: complex, yc_proportional_term: complex, hres_poles_s: ndarray, hres_residues: ndarray, hres_constant_term: complex, hres_proportional_term: complex, yc_alpha: ndarray, yc_beta: ndarray, hres_alpha: ndarray, hres_beta: ndarray)[source]

Bases: object

Discrete-time runtime coefficients of one scalar JMARTI modal channel.

The EMT runtime will later consume these coefficients directly instead of re-discretizing every pole on the fly. This keeps the time-stepping loop as lean as possible.

get_delay_step_count() int[source]

Return the integer delay in EMT steps.

Returns:

Integer delay in EMT steps.

get_hres_alpha() ndarray[source]

Return the exact discrete state-transition multipliers of Hres.

Returns:

Complex transition multipliers.

get_hres_beta() ndarray[source]

Return the exact discrete input gains of Hres.

Returns:

Complex input gains.

get_hres_constant_term() complex[source]

Return the constant term of Hres.

Returns:

Complex constant term of Hres.

get_hres_poles_s() ndarray[source]

Return the continuous-time poles of Hres.

Returns:

Complex pole vector of Hres.

get_hres_proportional_term() complex[source]

Return the proportional term of Hres.

Returns:

Complex proportional term of Hres.

get_hres_residues() ndarray[source]

Return the residues of Hres.

Returns:

Complex residue vector of Hres.

get_mode_index() int[source]

Return the modal channel index.

Returns:

Modal channel index.

get_residual_delay_s() float[source]

Return the unresolved sub-step delay in seconds.

Returns:

Residual delay in seconds.

get_tau_s() float[source]

Return the pure delay in seconds.

Returns:

Pure delay in seconds.

get_yc_alpha() ndarray[source]

Return the exact discrete state-transition multipliers of Yc.

Returns:

Complex transition multipliers.

get_yc_beta() ndarray[source]

Return the exact discrete input gains of Yc.

Returns:

Complex input gains.

get_yc_constant_term() complex[source]

Return the constant term of Yc.

Returns:

Complex constant term of Yc.

get_yc_poles_s() ndarray[source]

Return the continuous-time poles of Yc.

Returns:

Complex pole vector of Yc.

get_yc_proportional_term() complex[source]

Return the proportional term of Yc.

Returns:

Complex proportional term of Yc.

get_yc_residues() ndarray[source]

Return the residues of Yc.

Returns:

Complex residue vector of Yc.

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime_data.JMartiRuntimeData(time_step_s: float, line_length_m: float, phase_labels: tuple[str, ...], modal_transform: ndarray, modal_transform_inv: ndarray, reference_frequency_hz: float, mode_data: tuple[JMartiModeRuntimeData, ...])[source]

Bases: object

Runtime-ready discrete JMARTI data built from one offline fit bundle.

get_line_length_m() float[source]

Return the line length in meters.

Returns:

Line length in meters.

get_modal_transform() ndarray[source]

Return the frozen modal transform.

Returns:

Complex modal transform.

get_modal_transform_inv() ndarray[source]

Return the inverse frozen modal transform.

Returns:

Inverse modal transform.

get_mode_count() int[source]

Return the number of modes.

Returns:

Number of modes.

get_mode_data() tuple[JMartiModeRuntimeData, ...][source]

Return the discrete modal runtime records.

Returns:

Modal runtime tuple.

get_phase_labels() tuple[str, ...][source]

Return the ordered phase labels.

Returns:

Ordered phase-label tuple.

get_reference_frequency_hz() float[source]

Return the modal-reference frequency.

Returns:

Reference frequency in Hz.

get_time_step_s() float[source]

Return the EMT time step in seconds.

Returns:

EMT time step in seconds.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_runtime_data.build_jmarti_runtime_data(fit_bundle: JMartiFitBundle, time_step_s: float) JMartiRuntimeData[source]

Build runtime-ready discrete JMARTI coefficients from one offline fit bundle.

Parameters:
  • fit_bundle – Offline JMARTI fit bundle.

  • time_step_s – EMT time step in seconds.

Returns:

Runtime-ready JMARTI dataset.

Raises:

ValueError – If the time step is not strictly positive.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_vector_fit module

class VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_vector_fit.JMartiRationalModeFit(mode_index: int, target_name: str, poles_s: ndarray, residues: ndarray, constant_term: complex, proportional_term: complex, fit_error_rms: float, max_relative_error: float, iterations_completed: int, converged: bool, stable: bool)[source]

Bases: object

Scalar rational fit of one JMARTI modal target.

The first JMARTI implementation fits each modal channel independently. The object stores the resulting pole-residue form together with explicit error metrics so later passivity and runtime stages can inspect the fit quality.

get_constant_term() complex[source]

Return the fitted constant term.

Returns:

Complex constant term.

get_converged() bool[source]

Return whether the relocation loop converged.

Returns:

Boolean convergence flag.

get_fit_error_rms() float[source]

Return the relative RMS fit error.

Returns:

Relative RMS fit error.

get_iterations_completed() int[source]

Return the number of pole-relocation iterations performed.

Returns:

Completed iteration count.

get_max_relative_error() float[source]

Return the maximum pointwise relative fit error.

Returns:

Maximum relative fit error.

get_mode_index() int[source]

Return the modal channel index.

Returns:

Modal channel index.

get_poles_s() ndarray[source]

Return the fitted continuous-time poles.

Returns:

Complex pole vector.

get_proportional_term() complex[source]

Return the fitted proportional term.

Returns:

Complex proportional term.

get_residues() ndarray[source]

Return the fitted residues.

Returns:

Complex residue vector.

get_stable() bool[source]

Return whether every fitted pole is stable.

Returns:

Boolean stability flag.

get_target_name() str[source]

Return the modal target name.

Returns:

Modal target name.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_vector_fit.build_jmarti_complex_frequency_points(frequency_hz: Sequence[float]) ndarray[source]

Map one real frequency grid to the continuous-time imaginary axis.

Parameters:

frequency_hz – Frequency grid in Hz.

Returns:

Complex s-plane samples j*2*pi*f.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_vector_fit.build_jmarti_mode_vector_fit(frequency_hz: Sequence[float], response_values: ndarray, loewner_seed: JMartiModeLoewnerSeed, options: JMartiFitOptions | None = None) JMartiRationalModeFit[source]

Build one scalar Vector Fitting refinement from a Loewner seed.

Parameters:
  • frequency_hz – Frequency grid in Hz.

  • response_values – Complex scalar response samples on that grid.

  • loewner_seed – Loewner order/pole seed.

  • options – Optional user-configurable JMARTI fitting options.

Returns:

Scalar rational fit.

VeraGridEngine.Simulations.EMT.JMARTI_Sim.jmarti_vector_fit.evaluate_jmarti_rational_mode_fit(fit: JMartiRationalModeFit, frequency_hz: Sequence[float]) ndarray[source]

Evaluate one fitted scalar rational mode on the imaginary axis.

Parameters:
  • fit – Fitted scalar rational mode.

  • frequency_hz – Frequency grid in Hz.

Returns:

Complex response samples.

Module contents