### Install PolyChord dependency Source: https://gvcallen.github.io/paramrf/index.html Install the PolyChord solver and associated dependencies. ```bash $ pip install git+https://github.com/PolyChord/PolyChordLite.git anesthetic mpi4py ``` -------------------------------- ### start Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html The starting frequency in Hz. ```APIDOC ## property start ### Description The starting frequency in Hz. ### Returns - **float** - Start frequency. ``` -------------------------------- ### BulkConductor surface impedance example Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.materials.BulkConductor.html Creates a BulkConductor with copper conductivity and evaluates its surface impedance over a frequency range. The example shows the required imports and the call to properties(freq) to obtain the surface impedance zs. ```python import pmrf as prf from pmrf.materials import BulkConductor copper = BulkConductor(sigma=5.8e7) freq = prf.Frequency(start=1, stop=10, npoints=101, unit='ghz') zs = copper.properties(freq).zs ``` -------------------------------- ### Frequency constructor examples Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html Two examples of constructing Frequency objects: one with start/stop/npoints and unit, and one with a log sweep. ```python >>> wr1p5band = Frequency(start=500, stop=750, npoints=401, unit='ghz') >>> logband = Frequency(1, 1e9, 301, sweep_type='log') ``` -------------------------------- ### Declaring a parameter with constraints and scaling Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.param.html This example demonstrates how to define a model with parameters using constraints and scaling. It shows successful initialization and a ValueError when a constraint is violated. ```python import pmrf as prf from pmrf.constraints import Positive class RC(prf.Module): R: prf.Param = prf.param(constraint=Positive()) C: prf.Param = prf.param(constraint=Positive(), scale=1e-12) RC(1.0, 2.0) # RC(R=1., C=2.e-12) RC(-1.0, 2.0) # ValueError: out of bounds ``` -------------------------------- ### Benchmark Output Example Source: https://gvcallen.github.io/paramrf/_sources/skrf_comparison/performance.rst.txt Example output showing the performance difference between scikit-rf and ParamRF. ```text scikit-rf forward pass: 39.359 ms ParamRF forward pass: 1.197 ms Speedup: 32.9x ``` -------------------------------- ### Initialize and compute S-parameters for a MicrostripLine Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.lines.microstrip.MicrostripLine.html This example demonstrates how to instantiate a MicrostripLine with specific physical dimensions and material properties, then compute its S-parameters over a defined frequency range. ```python import pmrf as prf from pmrf.models import MicrostripLine from pmrf.materials import BulkConductor, ConstantDielectric phys_microstrip = MicrostripLine( w=4e-3, h=2.0e-3, dielectric=ConstantDielectric(ep_r=4.6, tand=0.025), conductor=BulkConductor(sigma=5.8e7), length=0.5 ) freq = prf.Frequency(start=1, stop=20, npoints=101, unit='ghz') s_phys = phys_microstrip.s(freq) ``` -------------------------------- ### Using Substrate with AbstractBuilder Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.materials.Substrate.html Shows how to define a model with a shared Substrate and inject it into multiple MicrostripLine instances. The example creates a Board class with two line widths and a shared substrate, then lists the named parameters ending with 'ep_r'. ```python >>> import pmrf as prf >>> from pmrf.materials import Substrate >>> from pmrf.models import AbstractBuilder, MicrostripLine >>> class Board(AbstractBuilder): ... substrate: Substrate ... w1: prf.Param ... w2: prf.Param ... def build(self): ... return (MicrostripLine(w=self.w1, substrate=self.substrate, length=0.1) ... ** MicrostripLine(w=self.w2, substrate=self.substrate, length=0.2)) >>> board = Board(substrate=Substrate(h=1.6e-3, dielectric=4.3), w1=1e-3, w2=2e-3) >>> [name for name in board.named_params() if name.endswith("ep_r")] ['substrate.dielectric.ep_r'] ``` -------------------------------- ### Import required packages for the tutorial Source: https://gvcallen.github.io/paramrf/tutorials/1_cable_fitting.html Imports matplotlib for plotting, skrf for touchstone reading, and pmrf (ParamRF). Ensure these packages are installed and import correctly before proceeding. ```python import matplotlib.pyplot as plt # for plotting import skrf as rf # for touchstone reading import pmrf as prf # ParamRF ``` -------------------------------- ### Create CoaxialLine and compute S-parameters Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.lines.coaxial.CoaxialLine.html Example from the class docstring: imports pmrf, CoaxialLine, BulkConductor, and ConstantDielectric; creates a CoaxialLine with d_in=0.9e-3, d_out=2.95e-3, dielectric with ep_r=1.5 and tand=0.0004, conductor with sigma=5.8e7, and length=0.5; then defines a frequency range from 1 to 20 GHz with 101 points and computes S-parameters using the s method. ```python import pmrf as prf from pmrf.models import CoaxialLine from pmrf.materials import BulkConductor, ConstantDielectric phys_cable = CoaxialLine( d_in=0.9e-3, d_out=2.95e-3, dielectric=ConstantDielectric(ep_r=1.5, tand=0.0004), conductor=BulkConductor(sigma=5.8e7), length=0.5 ) freq = prf.Frequency(start=1, stop=20, npoints=101, unit='ghz') s_phys = phys_cable.s(freq) ``` -------------------------------- ### Install distreqx dependency Source: https://gvcallen.github.io/paramrf/index.html Install the required fork of distreqx for Bayesian inference. ```bash $ pip install git+https://github.com/gvcallen/distreqx ``` -------------------------------- ### Install BlackJAX dependency Source: https://gvcallen.github.io/paramrf/index.html Install the BlackJAX Bayesian solver. ```bash $ pip install git+https://github.com/handley-lab/blackjax.git@v0.1.0-beta ``` -------------------------------- ### Create a StriplineLine and compute S-parameters Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.lines.stripline.StriplineLine.html Shows how to instantiate a StriplineLine with custom geometry and materials, then compute its S-parameters over a frequency range. The example uses ConstantDielectric and BulkConductor for the dielectric and conductor, respectively. ```python import pmrf as prf from pmrf.models import StriplineLine from pmrf.materials import BulkConductor, ConstantDielectric line = StriplineLine( w=2.655e-3, b=3.2e-3, t=35e-6, dielectric=ConstantDielectric(ep_r=2.2, tand=0.001), conductor=BulkConductor(sigma=5.8e7), length=0.1, ) freq = prf.Frequency(start=1, stop=20, npoints=101, unit='ghz') s = line.s(freq) ``` -------------------------------- ### Define a custom model expansion Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Model.html This example demonstrates how to implement an expand method for a custom 2-port model. It maps external ports to internal components and defines the netlist connections. ```python >>> def expand(self): ... # 1. Grab internal components ... L, C = self.inductor, self.capacitor ... ... # 2. Map our external ports to the internal components ... port_mapping = [ ... (L, 0), # External port 0 maps to Inductor port 0 ... (C, 1) # External port 1 maps to Capacitor port 1 ... ] ... ... # 3. Define the internal connections (the netlist) ... # Connect Inductor port 1 to Capacitor port 0 ... internal_connections = [ ... [(L, 1), (C, 0)] ... ] ... ... return port_mapping, internal_connections ``` -------------------------------- ### Model Setup for Derivatives and Sweeps Source: https://gvcallen.github.io/paramrf/_sources/examples/derivatives_and_sweeps.rst.txt Initializes a low-pass filter model with unconstrained parameters for use in derivative and sweep operations. ```python import pmrf as prf from pmrf.models import ShuntCapacitor, Inductor, Cascade c1 = ShuntCapacitor(C=prf.Unconstrained(1.0e-12), name='c1') l1 = Inductor(L=prf.Unconstrained(1.0e-9), name='l1') c2 = ShuntCapacitor(C=prf.Unconstrained(1.0e-12), name='c2') lpf = Cascade([c1, l1, c2]) ``` -------------------------------- ### Example for converter Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.field.html Shows how to use pmrf.field with a converter to convert a value to a JAX array on initialization. The converter is applied after __init__ or __post_init__, and the example asserts the field becomes a jax.Array. ```python class MyModule(eqx.Module): foo: Array = eqx.field(converter=jax.numpy.asarray) mymodule = MyModule(1.0) assert isinstance(mymodule.foo, jax.Array) ``` -------------------------------- ### from_f class method example Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html Shows how to create a Frequency object from a frequency vector using the from_f class method. ```python >>> f = np.linspace(75,100,101) >>> rf.Frequency.from_f(f, unit='GHz') ``` -------------------------------- ### Example for static Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.field.html Shows how to use pmrf.field with static=True to make a field part of the PyTree structure rather than a leaf, so it does not interact with JAX transforms. The example flattens the module and asserts that only the non-static field is a leaf. ```python class MyModule(eqx.Module): normal_field: int static_field: int = eqx.field(static=True) mymodule = MyModule("normal", "static") leaves, treedef = jax.tree_util.tree_flatten(mymodule) assert leaves == ["normal"] assert "static" in str(treedef) ``` -------------------------------- ### Create a PhaseLine instance Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.lines.ideal.PhaseLine.html Demonstrates how to instantiate a PhaseLine with a 90-degree electrical length and 50-ohm characteristic impedance at 1 GHz, then calculate its S-parameters over a frequency range. ```python import pmrf as prf from pmrf.models import PhaseLine # Create an ideal 90-degree (quarter-wave) 50-ohm line at 1 GHz quarter_wave = PhaseLine( z0=50.0, theta=90.0, f0=1e9 ) freq = prf.Frequency(start=0.5, stop=1.5, npoints=101, unit='ghz') s = quarter_wave.s(freq) ``` -------------------------------- ### Manipulate module parameters with at() Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Module.html Use the at() method to create a lens for surgical inspection or replacement of module parameters. This example demonstrates getting a parameter value and setting a new parameter object. ```python >>> import pmrf as prf >>> from pmrf.models import Resistor >>> module = Resistor(R=50.0, name="res") >>> module.at("res.R").get() 50.0 >>> updated = module.at("res.R").set(prf.Unconstrained(100.0)) ``` -------------------------------- ### Initialize and use DatasheetLine Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.lines.empirical.DatasheetLine.html Demonstrates how to instantiate a DatasheetLine with specific impedance, velocity factor, and loss coefficients, then calculate scattering parameters over a frequency range. ```python import pmrf as prf from pmrf.models import DatasheetLine cable = DatasheetLine( zn=50.0, vf=0.69, # Velocity factor (e.g., solid PTFE) k1=0.2, # Skin effect loss factor k2=0.01, # Dielectric loss factor length=1.0 ) freq = prf.Frequency(start=0.1, stop=10, npoints=201, unit='ghz') s = cable.s(freq) ``` -------------------------------- ### run(logposterior_fn, y0, args, key, init_samples=None, max_steps=None, **kwargs) Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.infer.AbstractJointSampler.html Execute the sampling algorithm. This method takes a log-posterior function, initial parameters, arguments, a random key, and optional initial samples and maximum steps, and returns a SampleResult. ```APIDOC ## run(logposterior_fn, y0, args, key, init_samples=None, max_steps=None, **kwargs) ### Description Execute the sampling algorithm. ### Method run ### Signature `abstractmethod run(logposterior_fn: Callable[[PyTree, Any], Any], y0: PyTree, args: PyTree[Any], key: Array, init_samples: PyTree | None = None, max_steps: int | None = None, **kwargs) -> SampleResult` ### Parameters - **logposterior_fn** (callable) - Required - A function taking the parameters and args as input and returning the log-posterior probability. - **y0** (PyTree) - Required - The initial parameters, either for shape reference or as a starting point. - **args** (Any) - Required - Args to pass to fn. - **key** (Array) - Required - A random JAX key. - **init_samples** (PyTree, optional) - Optional - An optional batched PyTree the same structure as y0 with initial samples to warm-start the algorithm. - **max_steps** (int, optional) - Optional - The maximum number of sampling steps to take. If None, implies there should be no limit. - **kwargs** - Optional - Runtime arguments forward to the solver backend. ### Returns - **results** (SampleResult) - An instance of `pmrf.infer.SampleResult`. ``` -------------------------------- ### Compute derivative of a model's response with respect to parameters Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.derivative.html Shows how to use pmrf.derivative to compute the sensitivity of a component's response (S21 magnitude) with respect to its parameters. The example creates a ShuntCapacitor model, defines an eval_fn that returns the S-matrix magnitude at a specific frequency, and then calls derivative to get the derivative. The derivative preserves the structural layout of the model, allowing access via .at('c1.C').get(). The output is -1.060e-01. ```python >>> import pmrf as prf >>> from pmrf.models import ShuntCapacitor >>> >>> freq = prf.Frequency(2.4, 2.4, 1, 'GHz') >>> cap = ShuntCapacitor(C=prf.Unconstrained(1.0e-12), name='c1') >>> >>> def eval_s21(model): ... return model.s_mag(freq)[0, 1, 0] ... >>> (d_cap,) = derivative(eval_s21, cap) >>> >>> # The structural layout of the model is preserved in the derivative >>> print(f"{d_cap.at('c1.C').get():.3e}") -1.060e-01 ``` -------------------------------- ### sample(_key: Key[jaxlib._jax.Array, '']) -> Array Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.distributions.Normal.html Draws a sample from the distribution. ```APIDOC ## sample(_key: Key[jaxlib._jax.Array, '']) -> Array ### Description Draws a sample from the distribution. See Distribution.sample. ``` -------------------------------- ### Install ParamRF via pip Source: https://gvcallen.github.io/paramrf/index.html Install the ParamRF library using pip. Requires Python 3.11 or higher. ```bash $ pip install paramrf ``` -------------------------------- ### Sampling from a Transformed distribution Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.distributions.Transformed.html Demonstrates how to initialize a Transformed distribution using a base distribution and a bijector, then generate samples. ```python dist = distrax.Normal(loc=0., scale=1.) bij = distrax.ScalarAffine(shift=jnp.asarray([3., 3., 3.])) transformed_dist = distrax.Transformed(distribution=dist, bijector=bij) samples = transformed_dist.sample(jax.random.key(0)) print(samples) # [2.7941577, 2.7941577, 2.7941577] ``` -------------------------------- ### start_scaled Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html The starting frequency in the specified unit. ```APIDOC ## property start_scaled ### Description The starting frequency in the specified unit. ### Returns - **float** - Start frequency in the specified unit. ``` -------------------------------- ### span Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html The frequency span (stop - start) in Hz. ```APIDOC ## property span ### Description The frequency span (stop - start) in Hz. ### Returns - **float** - Span in Hz. ``` -------------------------------- ### span_scaled Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html The frequency span (stop - start) in the specified unit. ```APIDOC ## property span_scaled ### Description The frequency span (stop - start) in the specified unit. ### Returns - **float** - Span in units. ``` -------------------------------- ### DatasheetLine Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.lines.empirical.DatasheetLine.html Class definition and constructor for DatasheetLine, including parameters and an example usage. ```APIDOC ## DatasheetLine ### Description Line defined by nominal impedance, velocity factor, and loss coefficients. ### Class `pmrf.models.components.lines.empirical.DatasheetLine` ### Constructor `DatasheetLine(_length_, _zn=50.0_, _vf=1.0_, _k1=0.0_, _k2=0.0_, _loss_coeffs_normalized=False_, *, _name=None_, _metadata=None_)` ### Parameters - **length** (Any) - Required - Length of the line. - **zn** (Param, default=50.0) - Nominal characteristic impedance. - **vf** (Param, default=1.0) - Velocity factor (ratio of propagation speed to the speed of light). - **k1** (Param, default=0.0) - Skin effect loss factor. - **k2** (Param, default=0.0) - Dielectric loss factor. - **loss_coeffs_normalized** (bool, default=False) - If true, use `k1` and `k2` directly. Otherwise, normalize them to the 100 MHz reference convention. - **name** (str | None, optional) - Name of the line. - **metadata** (Any, optional) - Additional metadata. ### Example ```python import pmrf as prf from pmrf.models import DatasheetLine cable = DatasheetLine( zn=50.0, vf=0.69, # Velocity factor (e.g., solid PTFE) k1=0.2, # Skin effect loss factor k2=0.01, # Dielectric loss factor length=1.0 ) freq = prf.Frequency(start=0.1, stop=10, npoints=201, unit='ghz') s = cable.s(freq) ``` ### Mathematical Formulation With normalized coefficients \(k_{1,norm}\) and \(k_{2,norm}\): \[ \alpha_c = k_{1,norm} \cdot \frac{\ln(10)}{20} \cdot \sqrt{\omega} \] \[ \alpha_d = k_{2,norm} \cdot \frac{\ln(10)}{20} \cdot \omega \] Per-unit-length parameters: \[ R = 2 z_n \alpha_c \] \[ L = \frac{z_n}{v_f c} \] \[ G = \frac{2 \alpha_d}{z_n} \] \[ C = \frac{1}{z_n v_f c} \] ``` -------------------------------- ### Benchmark Execution Entry Point Source: https://gvcallen.github.io/paramrf/_sources/skrf_comparison/performance.rst.txt Main execution block to run the defined benchmarks. ```python if __name__ == "__main__": run_forward_pass_benchmark() print() run_optimization_benchmark() ``` -------------------------------- ### __getitem__ Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.NetworkCollection.html Gets a network by index or name. If slice, returns a new NetworkCollection. ```APIDOC ## __getitem__ ### Description Gets a network by index or name. If slice, returns a new NetworkCollection. ### Method Operator overload ### Signature `__getitem__(key: int | str | slice) -> Network | NetworkCollection` ### Parameters - **key** (int, str, or slice) - If int, returns the network at that index. If str, returns the network with that name. If slice, returns a new NetworkCollection. ### Return Type Network or NetworkCollection ``` -------------------------------- ### run(loglikelihood_fn, prior_transform_fn, u0, args, key, init_cube_samples=None, max_steps=None, **kwargs) Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.infer.AbstractHypercubeSampler.html Executes the sampling algorithm for the AbstractHypercubeSampler class. ```APIDOC ## run(loglikelihood_fn, prior_transform_fn, u0, args, key, init_cube_samples=None, max_steps=None, **kwargs) ### Description Execute the sampling algorithm. ### Method run ### Parameters - **loglikelihood_fn** (callable) - Required - A function taking the physical parameters and args as input and returning the log-likelihood. - **prior_transform_fn** (callable) - Required - A function taking the hypercube parameters and args as input and returning the physical parameters. - **u0** (PyTree) - Required - The initial parameters in the unit hypercube, either for shape reference or as a starting point. - **args** (Any) - Required - Args to pass to fn. - **key** (Array) - Required - A random JAX key. - **init_cube_samples** (PyTree, optional) - Optional - An optional batched PyTree the same structure as u0 with initial hypercube samples to warm-start the algorithm. - **max_steps** (int, optional) - Optional - The maximum number of sampling steps to take. If None, implies there should be no limit. - **kwargs** - Optional - Runtime arguments forward to the solver backend. ### Returns An instance of `pmrf.infer.SampleResult`. ``` -------------------------------- ### Optimization Convergence Warning Source: https://gvcallen.github.io/paramrf/tutorials/1_cable_fitting.html Example of a UserWarning output indicating that the optimization process failed to converge. ```text /home/gvcallen/Masters/Python/paramrf/pmrf/optimize/base.py:204: UserWarning: Optimization failed to converge. Trying increasing the maximum number of iterations or loosening the solver tolerances. warnings.warn("Optimization failed to converge. Trying increasing the maximum number of iterations or loosening the solver tolerances.") ``` -------------------------------- ### Download and load measurement data from .s2p file Source: https://gvcallen.github.io/paramrf/tutorials/1_cable_fitting.html Downloads a sample .s2p file from the ParamRF repository, saves it locally, loads it into a scikit-rf Network with frequency in GHz, filters frequencies below 10 GHz, and plots the S-parameter data. The original file is available at https://www.minicircuits.com/WebStore/dashboard.html?model=CBN-1.5FT-SMSM%2B. ```python import os import urllib.request import skrf as rf import matplotlib.pyplot as plt base_url = "https://raw.githubusercontent.com/gvcallen/paramrf/main/docs/tutorials/data/" file_name = "CBN-1.5FT-SMSM.s2p" full_url = base_url + file_name local_dir = "data" local_filename = os.path.join(local_dir, file_name) os.makedirs(local_dir, exist_ok=True) if not os.path.exists(local_filename): print(f"Downloading {file_name} to {local_dir}/...") urllib.request.urlretrieve(full_url, local_filename) # Load the measured data into skrf using the new local path measured = rf.Network(local_filename, f_unit='GHz') measured = measured[measured.frequency.f_scaled < 10] fig, ax = plt.subplots(figsize=(4, 3)) measured.plot_s_db(m=0, n=0, ax=ax) ``` -------------------------------- ### Load constructor Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.models.components.ideal.Load.html Creates an ideal N-port load model with a specified reflection coefficient and reference impedance. ```APIDOC ## Load(_gamma: Any, _z0: Any = 50.0, _nports: int = 1, *, _name: str | None = None, _metadata: Any = None) ### Description Initializes an ideal N-port load model defined by its reflection coefficient gamma, referenced to impedance z0. ### Parameters - **gamma** (Any) - Required - The reflection coefficient. - **z0** (Any) - Optional - The reference impedance at which gamma is defined. Default is 50.0. - **nports** (int) - Optional - Number of ports. Default is 1. - **name** (str | None) - Optional - Name of the model. - **metadata** (Any) - Optional - Additional metadata. ### Attributes - **gamma** (Param) - The reflection coefficient. - **nports** (int) - Number of ports. - **z0** (Param) - The reference impedance at which gamma is defined. ``` -------------------------------- ### Optimize with Multiple Goals Source: https://gvcallen.github.io/paramrf/_sources/examples/model_optimization.rst.txt Demonstrates multi-objective optimization by defining both a passband matching goal and a stopband rejection goal. ```python stopband = prf.Frequency(1, 2, 101, 'GHz') result = minimize([ (Goal('s11_db', '<', -20), passband), (Goal('s21_db', '<', -40), stopband), ], lpf, solver=ScipyMinimize(method='L-BFGS-B')) ``` -------------------------------- ### Construct the Circuit model Source: https://gvcallen.github.io/paramrf/_sources/examples/circuit_models.rst.txt Initialize the Circuit model using the previously defined connections list. ```python from pmrf.models import Circuit pi_clc = Circuit(connections) ``` -------------------------------- ### Define a Capacitor Model using ABCD parameters Source: https://gvcallen.github.io/paramrf/_sources/examples/custom_models.rst.txt This example demonstrates defining a custom Capacitor model by inheriting from pmrf.Model and implementing the ABCD parameter method 'a'. ```python import pmrf as prf import jax.numpy as jnp class Capacitor(prf.Model): C: prf.Param def a(self, freq: prf.Frequency) -> jnp.ndarray: w, C = freq.w, self.C ones, zeros = jnp.ones_like(w), jnp.zeros_like(w) return jnp.array([ [ones, 1.0 / (1j * w * C)], [zeros, ones] ]).transpose(2, 0, 1) ``` -------------------------------- ### Declare a parameter with constraint and scale in ParamRF Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.parameters.param.html Example of using `prf.param` to declare parameters with constraints and scale in a custom `prf.Module`. Shows that out-of-bounds values raise a `ValueError`. ```python import pmrf as prf from pmrf.constraints import Positive class RC(prf.Module): R: prf.Param = prf.param(constraint=Positive()) C: prf.Param = prf.param(constraint=Positive(), scale=1e-12) RC(1.0, 2.0) # RC(R=1., C=2.e-12) RC(-1.0, 2.0) # ValueError: out of bounds ``` -------------------------------- ### Create ConstantDielectric and evaluate properties Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.materials.ConstantDielectric.html Shows how to instantiate a ConstantDielectric with ep_r=4.3 and tand=0.02, create a frequency axis from 1 to 10 GHz, and compute the complex permittivity. ```python import pmrf as prf from pmrf.materials import ConstantDielectric fr4 = ConstantDielectric(ep_r=4.3, tand=0.02) freq = prf.Frequency(start=1, stop=10, npoints=101, unit='ghz') eps = fr4.properties(freq).ep_r ``` -------------------------------- ### Frequency class properties Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.Frequency.html Properties of the Frequency class that return frequency-related values. These are read-only attributes that provide the start, stop, step, scaled values, and angular frequency vector. ```APIDOC ## Frequency class properties ### Description These properties return frequency-related values for the Frequency class. They are read-only attributes that provide the start, stop, step, scaled values, and angular frequency vector. ### Properties #### start - **Type**: float - **Description**: Scaled start frequency. #### step - **Type**: float - **Description**: The frequency step size in Hz for evenly spaced sweeps. #### step_scaled - **Type**: float - **Description**: The frequency step size in the specified unit for evenly spaced sweeps. #### stop - **Type**: float - **Description**: The stop frequency in Hz. #### stop_scaled - **Type**: float - **Description**: The stop frequency in the specified unit. #### w - **Type**: jnp.ndarray - **Description**: The angular frequency vector in radians/s. Angular frequency is defined as omega = 2 * pi * f. ### Attributes #### unit - **Type**: str - **Description**: The frequency unit. Possible options are "Hz", "kHz", "MHz", "GHz" or "THz". ### Returns Each property returns the value as described above. ``` -------------------------------- ### GradientDescent.__init__ Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.optimize.GradientDescent.html Constructor for the GradientDescent optimizer. Initializes the learning rate and termination tolerances. ```APIDOC ## GradientDescent.__init__ ### Description Initializes a GradientDescent optimizer with the given learning rate and termination tolerances. ### Method Constructor ### Parameters - **learning_rate** (float) - Required - Step size for the gradient descent updates. - **fatol** (float, default=1e-7) - Optional - Absolute tolerance of the function value for termination. - **step_atol** (float, default=1e-6) - Optional - Absolute tolerance of the gradients and step sizes for termination. - **step_rtol** (float, default=1e-6) - Optional - Relative tolerance of the gradients and step sizes for termination. - **norm** (Callable[[PyTree], Scalar], default=optx.max_norm) - Optional - Norm function used to evaluate the error. ``` -------------------------------- ### run(loglikelihood_fn, logprior_fn, y0, args, key, init_samples=None, max_steps=None, **kwargs) Source: https://gvcallen.github.io/paramrf/api/generated/pmrf.infer.AbstractSplitSampler.html Executes the sampling algorithm for samplers that require separate likelihood and prior densities. ```APIDOC ## run(loglikelihood_fn, logprior_fn, y0, args, key, init_samples=None, max_steps=None, **kwargs) ### Description Execute the sampling algorithm. This method is an abstract interface for samplers that require separate likelihood and prior densities, such as modern Nested Sampling implementations. ### Method run ### Parameters - **loglikelihood_fn** (callable) - Required - A function taking the parameters and args as input and returning the log-likelihood. - **logprior_fn** (callable) - Required - A function taking the parameters and args as input and returning the log prior probability. - **y0** (PyTree) - Required - The initial parameters, either for shape reference or as a starting point. - **args** (Any) - Required - Args to pass to fn. - **key** (Array) - Required - A random JAX key. - **init_samples** (PyTree, optional) - Optional - An optional batched PyTree the same structure as y0 with initial samples to warm-start the algorithm. - **max_steps** (int, optional) - Optional - The maximum number of sampling steps to take. If None, implies there should be no limit. - **kwargs** - Optional - Runtime arguments forward to the solver backend. ### Returns An instance of `pmrf.infer.SampleResult`. ```