mercurial.core.thermodynamics module

Thermodynamic quantities for free energy calculation.

class mercurial.core.thermodynamics.EffectiveTemperature(initial_temp: float = 1.0, env_temp: float = 1.0, cooling_rate: float = 0.01, heating_coeff: float = 0.1)[source]

Bases: object

Dynamic effective temperature T_eff. Evolves according to: dT/dt = -α (T - T_env) + β dE/dt

Methods

update(dt, dE_dt)

Update temperature based on energy change.

update(dt: float, dE_dt: float) float[source]

Update temperature based on energy change.

class mercurial.core.thermodynamics.FullFreeEnergy(temperature: EffectiveTemperature | None = None, entropy_weights: tuple = (1.0, 1.0, 1.0))[source]

Bases: object

Implements F = E - T_eff * S_gen.

Methods

compute(pattern[, state_velocities, ...])

F = E - T_eff * S_gen + λ * ||θ||².

generalized_entropy(pattern[, state_velocities])

S_gen = β_info·I + β_therm·S_therm + β_ph·(1 - coherence).

__init__(temperature: EffectiveTemperature | None = None, entropy_weights: tuple = (1.0, 1.0, 1.0))[source]
Parameters:
temperatureEffectiveTemperature, optional

If None, uses constant T_eff = 1.0.

entropy_weightstuple

(β_info, β_therm, β_ph) for generalized entropy.

compute(pattern, state_velocities: ndarray | None = None, regularization_penalty: float = 0.0) float[source]

F = E - T_eff * S_gen + λ * ||θ||².

generalized_entropy(pattern, state_velocities: ndarray | None = None) float[source]

S_gen = β_info·I + β_therm·S_therm + β_ph·(1 - coherence).

class mercurial.core.thermodynamics.InternalEnergy[source]

Bases: object

Computes internal energy E(P) of a pattern. E = constraint_violation + kinetic_energy + potential_energy

Methods

constraint_energy(constraint_violation[, ...])

E_constraint = κ * ||C(v)||².

kinetic_energy(state_velocities[, mass])

E_kin = ½ m Σ v_i².

potential_energy(state_positions[, ...])

E_pot = ½ k Σ (x_i - x₀)² (harmonic approximation).

total_energy(pattern[, state_velocities])

E_total = E_constraint + E_kin + E_pot.

static constraint_energy(constraint_violation: float, stiffness: float = 1.0) float[source]

E_constraint = κ * ||C(v)||².

static kinetic_energy(state_velocities: ndarray, mass: float = 1.0) float[source]

E_kin = ½ m Σ v_i².

static potential_energy(state_positions: ndarray, spring_constant: float = 0.1) float[source]

E_pot = ½ k Σ (x_i - x₀)² (harmonic approximation).

classmethod total_energy(pattern, state_velocities: ndarray | None = None) float[source]

E_total = E_constraint + E_kin + E_pot.