pycsamt.agents.pinn_agent#
pycsamt.agents.pinn_agent#
PINNInversionAgent wraps
PINNInverter1D,
PINNInverter2D, and
PINNInverter3D.
Physics-informed optimisation requires no labelled training data. Model parameters are updated by gradient descent on the Wait (1954) MT forward- physics loss.
Classes
|
PINN-based MT inversion without labelled data. |
- class pycsamt.agents.pinn_agent.PINNInversionAgent(*, dim=1, n_layers=10, depth_max=2000.0, smoothness_weight=0.01, lateral_weight=0.005, graph_weight=0.005, radius=5000.0, epochs=None, lr=0.01, solver='mt1d', comp='xy', api_key=None, model=None, llm_provider='claude')[source]#
Bases:
BaseAgentPINN-based MT inversion without labelled data.
Optimises a layered Earth by minimising a physics-informed loss via Adam gradient descent. Supports 1-D per-station, joint 2-D profile, and quasi-3-D graph-coupled inversion.
- Parameters:
dim (overrides) – Dimensionality. Default
1.n_layers (overrides) – Number of layers including the halfspace. Default
10.depth_max (float) – Maximum investigation depth in metres. Default
2000.0.smoothness_weight (float) – Vertical regularisation weight. Default
0.01.lateral_weight (float) – Lateral smoothness weight (2-D only). Default
0.005.graph_weight (float) – Graph-Laplacian spatial weight (3-D only). Default
0.005.radius (float) – Edge radius in metres for the 3-D graph. Default
5000.0.epochs (overrides) – Adam iterations.
Noneuses 500 for 1-D and 300 for 2-D / 3-D.lr (float) – Adam learning rate. Default
1e-2.solver ({"mt1d", "csamt1d"}) – Physics solver. Default
"mt1d".comp (str) – Impedance component (1-D only). Default
"xy".api_key (str | None) – LLM configuration (optional).
model (str | None) – LLM configuration (optional).
llm_provider (str) – LLM configuration (optional).
keys (Output data)
----------
data (sites / path observed)
dir (output_dir optional figure/save)
dim
epochs
n_layers
keys
----------------
object (inverter fitted inverter)
(n_layers (section ndarray) – log10-rho section matrix
n_stations) – log10-rho section matrix
(1-D) (models list of LayeredModel)
int (n_stations)
{station (rms_per_station dict)
float (rms_global)
None (residuals_df pandas.DataFrame or)
None
dict (figure_paths)
dict
Examples
>>> agent = PINNInversionAgent( ... dim=1, n_layers=10, epochs=200 ... ) >>> res = agent.execute( ... {"path": "/data/L22PLT"} ... ) >>> res["rms_global"] 0.18
- SYSTEM_PROMPT: str = 'You are an expert in physics-informed neural-network\ninversion for MT/CSAMT geophysics.\nGiven a PINN inversion result write 4-5 sentences:\n1. State dimensionality (1-D/2-D/3-D) and convergence.\n2. Report final RMS (log10 rho-ohm-m) and data fit.\n3. Describe the resistivity structure recovered.\n4. Flag stations or regions with high residuals.\n5. Recommend adjustments to epochs, regularisation,\n or whether to switch to a hybrid approach.\nReply in plain scientific English.\n'#
Override in subclasses to give the LLM its domain expertise.
- execute(input_data)[source]#
Run this agent on input_data and return an
AgentResult.Subclasses must implement this method. The contract:
Reset
self._last_cost = 0.0at the top.Record wall-clock time with
t0 = time.time().Return
AgentResult(elapsed_seconds=time.time()-t0, cost_estimate_usd=self._last_cost, ...).
- Parameters:
- Return type: