Spaces:
Running
Running
File size: 1,385 Bytes
31226fd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """Bidirectional ohmic coupling kept separate from directed chemical synapses."""
from __future__ import annotations
from dataclasses import asdict, dataclass
from .biophysical_contracts import ModelProvenance, ModelTimescale
@dataclass(frozen=True, slots=True)
class GapJunctionConfig:
enabled: bool = False
conductance: float = 0.01
def __post_init__(self) -> None:
if self.conductance < 0.0:
raise ValueError("conductance must be >= 0")
@dataclass(slots=True)
class GapJunction:
neuron_a: int
neuron_b: int
config: GapJunctionConfig = GapJunctionConfig()
def __post_init__(self) -> None:
if self.neuron_a == self.neuron_b:
raise ValueError("gap junction endpoints must differ")
@property
def provenance_tag(self) -> ModelProvenance:
return ModelProvenance(
model_id="gap-junction-ohmic-v1",
version="mhrn-experimental-1",
timescale=ModelTimescale.TICK,
enabled=self.config.enabled,
parameters=asdict(self.config),
)
def currents(self, voltage_a: float, voltage_b: float) -> tuple[float, float]:
if not self.config.enabled:
return 0.0, 0.0
current_a = self.config.conductance * (voltage_b - voltage_a)
return current_a, -current_a
__all__ = ["GapJunction", "GapJunctionConfig"]
|