Skip to content

Particle in the well k x^2 e^-x

A particle moving without friction in the potential U(x) = k x² e^-x.

  • Name: particle_in_a_well
  • Field: physics/mechanics
  • Formalism: ordinary differential equations
  • References: Starkovich 2021

Factory

@register_model(
    field='physics/mechanics',
    tags=('mechanics', 'ode', 'potential', 'hamiltonian'),
    references=('Starkovich 2021',),
    defaults={'until': 20.0, 'dt': 0.05},
)
def particle_in_a_well(x: float = 1.0, v: float = 0.5, *, k: float = 2.0, m: float = 1.0) -> System:
    """Return a particle moving without friction in the potential `U(x) = k x² e^-x`.

    The potential has a stable equilibrium at `x = 0` and an unstable one at `x = 2`, the top of a barrier of height
    `4 k e^-2`. A particle in the well with less energy than the barrier oscillates, and one with more escapes to
    large `x`.

    Args:
        x:
            The initial position.

        v:
            The initial velocity.

        k:
            The strength of the potential.

        m:
            The mass of the particle.

    Returns:
        system:
            The model, with the particle `particle` and its position `particle.x` in one dimension.

    Examples:
        >>> from skcomplex.models.physics.mechanics import particle_in_a_well
        >>> particle_in_a_well(k=3.0).interactions[0].k
        3.0
    """
    return System(
        elements=[MassPointElement('particle', x=x, x_d1=v, m=m)],
        interactions=[ExponentialWellInteraction('well', target='particle', k=k)],
        space=ContinuousSpace(n_dim=1),
    )

Components

class MassPointElement(PointElement):
    """Point mass, a point whose position `x` has order 2, with its velocity `x_d1` and a mass `m`.

    The forces on the point divide by the mass through their divisor `'m'`.

    Args:
        label:
            The label of the point.

        x:
            The initial position. A number applies to every component.

        x_d1:
            The initial velocity. A number applies to every component.

        visual:
            How the point is drawn, or `None` for `default_visual_`.

        m:
            The mass.

    Attributes:
        default_visual_:
            Points at the positions.

    Examples:
        >>> from skcomplex.models.physics.common.particles import MassPointElement
        >>> MassPointElement('ball', x=[0.0, 1.0], m=2.0).m
        2.0
    """

    def __init__(
        self,
        label: str,
        x: npt.ArrayLike = 0.0,
        x_d1: npt.ArrayLike = 0.0,
        visual: VisualSpec | None = None,
        *,
        m: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 1.0,
    ) -> None:
        super().__init__(label, x=x, x_d1=x_d1, visual=visual)
        self.m = m

class ExponentialWellInteraction(PotentialEnergyInteraction):
    """Potential `k x² e^-x` on a particle in one dimension, a well at `x = 0` behind a barrier at `x = 2`.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the particle.

        k:
            The strength of the potential.

    Examples:
        >>> from skcomplex.models.physics.mechanics import ExponentialWellInteraction
        >>> ExponentialWellInteraction('well', target='particle', k=2.0).k
        2.0
    """

    def __init__(
        self,
        label: str,
        *,
        target: Annotated[str, RoleSpec()],
        k: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 2.0,
    ) -> None:
        super().__init__(label, target=target)
        self.k = k

    def _get_potential(self, s: SimpleNamespace) -> Expression:
        """Return `k x² e^-x`.

        Args:
            s:
                The namespace of the symbols the energy can use.

        Returns:
            energy:
                The potential energy as a symbolic expression.
        """
        position = s.target.x[0]
        return s.k * position**2 * exp(-position)

Equations

particle.x[0]: diff(x_particle_0(t), t, t) == (k_well*e^(-x_particle_0(t))*x_particle_0(t)^2 - 2*k_well*e^(-x_particle_0(t))*x_particle_0(t))/m_particle