diff --git a/plots/relativistic/relativistic_force_for_different_acceleration_configurations.py b/plots/relativistic/relativistic_force_for_different_acceleration_configurations.py index ca1c9b5eb..c7d650065 100644 --- a/plots/relativistic/relativistic_force_for_different_acceleration_configurations.py +++ b/plots/relativistic/relativistic_force_for_different_acceleration_configurations.py @@ -4,6 +4,7 @@ from sympy import Symbol, plot, sqrt from sympy.physics.units import speed_of_light from symplyphysics import Vector, vector_magnitude +from symplyphysics.core.symbols.quantities import evaluate_expression from symplyphysics.laws.relativistic.vector import force_acceleration_relation Datum = namedtuple("Datum", "label acceleration") @@ -37,9 +38,9 @@ for datum_ in data_: vector = force_acceleration_relation.force_law(datum_.acceleration, velocity) expr = vector_magnitude(vector).subs(force_acceleration_relation.rest_mass, 1) - + expr_value = evaluate_expression(expr) sub_plot = plot( - expr, + expr_value, (reduced_velocity, 0, 0.97), label=datum_.label, show=False, diff --git a/symplyphysics/core/symbols/quantities.py b/symplyphysics/core/symbols/quantities.py index 63a8ffbda..d8758478b 100644 --- a/symplyphysics/core/symbols/quantities.py +++ b/symplyphysics/core/symbols/quantities.py @@ -20,6 +20,10 @@ def __new__(cls, display_latex: Optional[str] = None, **assumptions: Any) -> Self: name = next_name("QTY") + # Latex symbol is set in SymPy Quantity, not in DimensionSymbol, due to Latex printer + # specifics + display_symbol = name if display_symbol is None else display_symbol + display_latex = display_symbol if display_latex is None else display_latex obj = SymQuantity.__new__(cls, name, None, display_latex, None, None, None, False, **assumptions) return obj @@ -75,3 +79,18 @@ def evaluate_quantity(quantity: Expr, **kwargs: Any) -> Quantity: scale_factor_ = quantity.scale_factor.evalf(**kwargs) dimension = quantity.dimension return Quantity(scale_factor_, dimension=dimension) + + +def evaluate_expression(expr: Expr, **kwargs: Any) -> Expr: + quantities = [] + def _evaluate_inner(expr: Expr) -> None: + for arg in expr.args: + if isinstance(arg, SymQuantity): + quantities.append(arg) + continue + if isinstance(arg, Expr): + _evaluate_inner(arg) + _evaluate_inner(expr) + for q in quantities: + expr = expr.subs(q, q.scale_factor.evalf(**kwargs)) + return expr diff --git a/symplyphysics/core/symbols/symbols.py b/symplyphysics/core/symbols/symbols.py index faef5c4fe..cf18fdf41 100644 --- a/symplyphysics/core/symbols/symbols.py +++ b/symplyphysics/core/symbols/symbols.py @@ -188,6 +188,9 @@ def __init__(cls, display_name = str(cls.name) if display_symbol is None else display_symbol super().__init__(display_name, dimension, display_latex=display_latex) + def __repr__(cls) -> str: + return str(cls.display_name) + # Symbol and Function have generated names, hence their display is not readable. # Use custom implementation of the PrettyPrinter to convert real symbol names diff --git a/symplyphysics/definitions/admittance_is_inverse_impedance.py b/symplyphysics/definitions/admittance_is_inverse_impedance.py index be6dd54c6..4a231e3d9 100644 --- a/symplyphysics/definitions/admittance_is_inverse_impedance.py +++ b/symplyphysics/definitions/admittance_is_inverse_impedance.py @@ -25,9 +25,7 @@ r""" :code:`Y = 1 / Z` -Latex: - .. math:: - Y = \frac{1}{Z} +:laws:latex:: """ diff --git a/symplyphysics/definitions/boltzmann_factor_via_state_energy_and_temperature.py b/symplyphysics/definitions/boltzmann_factor_via_state_energy_and_temperature.py index 7c536515d..54ce57038 100644 --- a/symplyphysics/definitions/boltzmann_factor_via_state_energy_and_temperature.py +++ b/symplyphysics/definitions/boltzmann_factor_via_state_energy_and_temperature.py @@ -8,39 +8,30 @@ **Notation:** #. :math:`\exp` is the exponential function. -#. :math:`k_\text{B}` (:code:`k_B`) is the Boltzmann constant. """ from sympy import Eq, exp from symplyphysics import ( + quantities, units, dimensionless, Quantity, - Symbol, validate_input, validate_output, symbols, clone_symbol, convert_to_float, + SymbolNew, ) -boltzmann_factor = Symbol("boltzmann_factor", dimensionless) +boltzmann_factor = SymbolNew("f", dimensionless) """ Boltzmann factor. - -Symbol: - :code:`f` """ -energy_of_state = Symbol("energy_of_state", units.energy) +energy_of_state = SymbolNew("E[i]", units.energy, display_latex="E_i") """ Energy of state :math:`i`. - -Symbol: - :code:`E_i` - -Latex: - :math:`E_i` """ equilibrium_temperature = clone_symbol(symbols.thermodynamics.temperature) @@ -48,14 +39,17 @@ Equilibrium :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the system. """ +boltzmann_constant = quantities.boltzmann_constant +""" +:attr:`~symplyphysics.quantities.boltzmann_constant` +""" + definition = Eq(boltzmann_factor, - exp(-1 * energy_of_state / (units.boltzmann_constant * equilibrium_temperature))) -r""" -:code:`f = exp(-1 * E_i / (k_B * T))` + exp(-1 * energy_of_state / (boltzmann_constant * equilibrium_temperature))) +""" +:laws:symbol:: -Latex: - .. math:: - f = \exp{\left( - \frac{E_i}{k_\text{B} T} \right)} +:laws:latex:: """ diff --git a/symplyphysics/definitions/capacitance_from_charge_and_voltage.py b/symplyphysics/definitions/capacitance_from_charge_and_voltage.py index 7c328aac7..02dbb4dce 100644 --- a/symplyphysics/definitions/capacitance_from_charge_and_voltage.py +++ b/symplyphysics/definitions/capacitance_from_charge_and_voltage.py @@ -8,39 +8,28 @@ """ from sympy import Eq, solve -from symplyphysics import units, Quantity, Symbol, validate_input, validate_output +from symplyphysics import units, Quantity, SymbolNew, validate_input, validate_output -capacitance = Symbol("capacitance", units.capacitance) +capacitance = SymbolNew("C", units.capacitance) """ Capacitance of the object. - -Symbol: - :code:`C` """ -charge = Symbol("charge", units.charge) +charge = SymbolNew("q", units.charge) """ Charge accumulated in the object. - -Symbol: - :code:`q` """ -voltage = Symbol("voltage", units.voltage) +voltage = SymbolNew("V", units.voltage) """ Voltage across the object. - -Symbol: - :code:`V` """ definition = Eq(capacitance, charge / voltage) -r""" -:code:`C = q / V` +""" +:laws:symbol:: -Latex: - .. math:: - C = \frac{q}{V} +:laws:latex:: """ diff --git a/symplyphysics/definitions/compliance_is_inverse_stiffness.py b/symplyphysics/definitions/compliance_is_inverse_stiffness.py index b3a206db6..7f19de59a 100644 --- a/symplyphysics/definitions/compliance_is_inverse_stiffness.py +++ b/symplyphysics/definitions/compliance_is_inverse_stiffness.py @@ -10,34 +10,28 @@ from symplyphysics import ( units, Quantity, - Symbol, + SymbolNew, validate_input, validate_output, ) -compliance = Symbol("compliance", units.length / units.force) +compliance = SymbolNew("c", units.length / units.force) """ Compliance of the spring. - -Symbol: - :code:`c` """ -stiffness = Symbol("stiffness", units.force / units.length) +stiffness = SymbolNew("k", units.force / units.length) """ Stiffness of the spring. - -Symbol: - :code:`k` """ +# TODO: use autogenerated representation, but fix (1 / k) code representation before + definition = Eq(compliance, 1 / stiffness) -r""" +""" :code:`c = 1 / k` -Latex: - .. math:: - c = \frac{1}{k} +:laws:latex:: """ diff --git a/symplyphysics/definitions/compressibility_factor_is_deviation_from_ideal_gas.py b/symplyphysics/definitions/compressibility_factor_is_deviation_from_ideal_gas.py index a3a994a6b..0614f3f2d 100644 --- a/symplyphysics/definitions/compressibility_factor_is_deviation_from_ideal_gas.py +++ b/symplyphysics/definitions/compressibility_factor_is_deviation_from_ideal_gas.py @@ -7,10 +7,6 @@ ideal gas behaviour becomes more prominent the closer the gas is to a phase change, the lower the temperature or the larger the pressure. -**Notation:** - -#. :math:`R` is the molar gas constant. - **Notes:** #. Can be equivalently defined as the ratio of the molar volume :math:`\frac{V}{n}` of the real gas to the @@ -24,46 +20,35 @@ from sympy import Eq from symplyphysics import ( + quantities, units, dimensionless, Quantity, - Symbol, + SymbolNew, validate_input, validate_output, symbols, convert_to_float, ) -compressibility_factor = Symbol("compressibility_factor", dimensionless) +compressibility_factor = SymbolNew("Z", dimensionless) """ Compressibility factor of the real gas. - -Symbol: - :code:`Z` """ -pressure = Symbol("pressure", units.pressure) +pressure = SymbolNew("p", units.pressure) """ Pressure of the gas. - -Symbol: - :code:`p` """ -volume = Symbol("volume", units.volume) +volume = SymbolNew("V", units.volume) """ Volume of the gas. - -Symbol: - :code:`V` """ -amount_of_substance = Symbol("amount_of_substance", units.amount_of_substance) +amount_of_substance = SymbolNew("n", units.amount_of_substance) """ Amount of gas substance. - -Symbol: - :code:`n` """ temperature = symbols.thermodynamics.temperature @@ -71,14 +56,17 @@ Gas :attr:`~symplyphysics.symbols.thermodynamics.temperature`. """ +molar_gas_constant = quantities.molar_gas_constant +""" +:attr:`~symplyphysics.quantities.molar_gas_constant` +""" + definition = Eq(compressibility_factor, - (pressure * volume) / (amount_of_substance * units.molar_gas_constant * temperature)) -r""" -:code:`Z = (p * V) / (n * R * T)` + (pressure * volume) / (amount_of_substance * molar_gas_constant * temperature)) +""" +:laws:symbol:: -Latex: - .. math:: - Z = \frac{p V}{n R T} +:laws:latex:: """ diff --git a/symplyphysics/definitions/current_is_charge_derivative.py b/symplyphysics/definitions/current_is_charge_derivative.py index 2e803331b..16be570ba 100644 --- a/symplyphysics/definitions/current_is_charge_derivative.py +++ b/symplyphysics/definitions/current_is_charge_derivative.py @@ -7,39 +7,28 @@ """ from sympy import (Eq, Derivative) -from symplyphysics import (units, Quantity, Function, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, FunctionNew, SymbolNew, validate_input, validate_output) -current = Function("current", units.current) +current = FunctionNew("I(t)", units.current, display_latex="I") """ Electric current as a function of time. - -Symbol: - :code:`I(t)` """ -charge = Function("charge", units.charge) +charge = FunctionNew("q(t)", units.charge, display_latex="q") """ Electric charge as a function of time. - -Symbol: - :code:`q(t)` """ -time = Symbol("time", units.time) +time = SymbolNew("t", units.time) """ Time. - -Symbol: - :code:`t` """ definition = Eq(current(time), Derivative(charge(time), time)) -r""" -:code:`I(t) = Derivative(q(t), t)` +""" +:laws:symbol:: -Latex: - .. math:: - I(t) = \frac{d q}{d t} +:laws:latex:: """ diff --git a/symplyphysics/definitions/damped_harmonic_oscillator_equation.py b/symplyphysics/definitions/damped_harmonic_oscillator_equation.py index 9ded0f9ed..6bc1097de 100644 --- a/symplyphysics/definitions/damped_harmonic_oscillator_equation.py +++ b/symplyphysics/definitions/damped_harmonic_oscillator_equation.py @@ -7,67 +7,50 @@ assuming the body only moves in one direction. """ -from sympy import Derivative, dsolve +from sympy import Derivative, Eq, dsolve from symplyphysics import ( units, Quantity, - Symbol, - Function, + SymbolNew, + FunctionNew, validate_input, validate_output, angle_type, dimensionless, ) -displacement = Function("displacement", units.length) +displacement = FunctionNew("x(t)", units.length, display_latex="x") """ Displacement of the oscillating body as a function of time. - -Symbol: - :code:`x(t)` """ -time = Symbol("time", units.time, positive=True) +time = SymbolNew("t", units.time, positive=True) """ Time. - -Symbol: - :code:`t` """ -undamped_angular_frequency = Symbol("undamped_angular_frequency", +undamped_angular_frequency = SymbolNew("w", angle_type / units.time, + display_latex="\\omega", positive=True) -r""" +""" Undamped angular frequency of the oscillator. - -Symbol: - :code:`w` - -Latex: - :math:`\omega` """ -damping_ratio = Symbol("damping_ratio", dimensionless, positive=True) -r""" +damping_ratio = SymbolNew("z", dimensionless, display_latex="\\zeta", positive=True) +""" Damping ratio, which critically determines the behavior of the system. - -Symbol: - :code:`z` - -Latex: - :math:`\zeta` """ -definition = (Derivative(displacement(time), time, 2) + - 2 * damping_ratio * undamped_angular_frequency * Derivative(displacement(time), time) + - undamped_angular_frequency**2 * displacement(time)) -r""" -:code:`Derivative(x(t), (t, 2)) + 2 * z * w * Derivative(x(t), t) + w^2 * x(t) = 0` +definition = Eq( + Derivative(displacement(time), time, 2) + + 2 * damping_ratio * undamped_angular_frequency * Derivative(displacement(time), time) + + undamped_angular_frequency**2 * displacement(time), + 0) +""" +:laws:symbol:: -Latex: - .. math:: - \frac{d^2 x}{dt^2} + 2 \zeta \omega \frac{d x}{d t} + \omega^2 x(t) = 0 +:laws:latex:: """ diff --git a/symplyphysics/definitions/density_from_mass_volume.py b/symplyphysics/definitions/density_from_mass_volume.py index 1c7a3f4f4..1594157c1 100644 --- a/symplyphysics/definitions/density_from_mass_volume.py +++ b/symplyphysics/definitions/density_from_mass_volume.py @@ -8,17 +8,11 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output, symbols) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output, symbols) -density = Symbol("density", units.mass / units.volume) -r""" +density = SymbolNew("rho", units.mass / units.volume, display_latex="\\rho") +""" Volumetric density of the object. - -Symbol: - :code:`rho` - -Latex: - :math:`\rho` """ mass = symbols.basic.mass @@ -26,21 +20,16 @@ :attr:`~symplyphysics.symbols.basic.mass` of the object. """ -volume = Symbol("volume", units.volume) +volume = SymbolNew("V", units.volume) """ Volume of the object. - -Symbol: - :code:`V` """ definition = Eq(density, mass / volume) -r""" -:code:`rho = m / V` +""" +:laws:symbol:: -Latex: - .. math:: - \rho = \frac{m}{V} +:laws:latex:: """ diff --git a/symplyphysics/definitions/electrical_conductivity_is_inversed_resistance.py b/symplyphysics/definitions/electrical_conductivity_is_inversed_resistance.py index 55b6b7a3e..fd5c15dda 100644 --- a/symplyphysics/definitions/electrical_conductivity_is_inversed_resistance.py +++ b/symplyphysics/definitions/electrical_conductivity_is_inversed_resistance.py @@ -7,34 +7,25 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output) -conductivity = Symbol("conductivity", units.conductance) -r""" +conductivity = SymbolNew("sigma", units.conductance, display_latex="\\sigma") +""" Condutivity of the object. - -Symbol: - :code:`sigma` - -Latex: - :math:`\sigma` """ -resistance = Symbol("resistance", units.impedance) +resistance = SymbolNew("R", units.impedance) """ Resistance of the object. - -Symbol: - :code:`R` """ +# TODO: use autogenerated representation, but fix (1 / R) code representation before + definition = Eq(conductivity, 1 / resistance) -r""" +""" :code:`sigma = 1 / R` -Latex: - .. math:: - \sigma = \frac{1}{R} +:laws:latex:: """ diff --git a/symplyphysics/definitions/harmonic_oscillator_is_second_derivative_equation.py b/symplyphysics/definitions/harmonic_oscillator_is_second_derivative_equation.py index de18c635d..a71ea3900 100644 --- a/symplyphysics/definitions/harmonic_oscillator_is_second_derivative_equation.py +++ b/symplyphysics/definitions/harmonic_oscillator_is_second_derivative_equation.py @@ -13,7 +13,7 @@ """ from sympy import (Derivative, Eq, cos, solve, symbols, Function as SymFunction) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output) from symplyphysics.core.expr_comparisons import expr_equals # Can have various dimensions - do not specify it @@ -23,31 +23,30 @@ Symbol: :code:`x(t)` + +Latex: + :math:`x` """ -angular_frequency = Symbol("angular_frequency", units.frequency) -r""" +angular_frequency = SymbolNew("w", units.frequency, display_latex="\\omega") +""" Angular frequency of the oscillator. - -Symbol: - :code:`w` - -Latex: - :math:`\omega` """ -time = Symbol("time", units.time) +time = SymbolNew("t", units.time) """ Time. - -Symbol: - :code:`t` """ definition = Eq(Derivative(displacement(time), (time, 2)), -angular_frequency**2 * displacement(time)) r""" -:code:`Derivative(x(t), (t, 2)) = -1 * w^2 * x(t)` +.. only:: comment + + `displacement` does not have specific dimension. We do not have autogenerated + documentation for such symbols. + +:code:`Derivative(x(t), (t, 2)) = -w^2*x(t)` Latex: .. math:: diff --git a/symplyphysics/definitions/heat_capacity_ratio.py b/symplyphysics/definitions/heat_capacity_ratio.py index 9b759a61d..d49a11c48 100644 --- a/symplyphysics/definitions/heat_capacity_ratio.py +++ b/symplyphysics/definitions/heat_capacity_ratio.py @@ -18,52 +18,32 @@ units, dimensionless, Quantity, - Symbol, + SymbolNew, validate_input, validate_output, convert_to_float, ) -heat_capacity_ratio = Symbol("heat_capacity_ratio", dimensionless) -r""" +heat_capacity_ratio = SymbolNew("gamma", dimensionless, display_latex="\\gamma") +""" Heat capacity ratio of the system. - -Symbol: - :code:`gamma` - -Latex: - :math:`\gamma` """ -isobaric_heat_capacity = Symbol("isobaric_heat_capacity", units.energy / units.temperature) +isobaric_heat_capacity = SymbolNew("C_p", units.energy / units.temperature) """ Heat capacity of the system at constant pressure. - -Symbol: - :code:`C_p` - -Latex: - :math:`C_p` """ -isochoric_heat_capacity = Symbol("isochoric_heat_capacity", units.energy / units.temperature) +isochoric_heat_capacity = SymbolNew("C_V", units.energy / units.temperature) """ Heat capacity of the system at constant volume. - -Symbol: - :code:`C_V` - -Latex: - :math:`C_V` """ definition = Eq(heat_capacity_ratio, isobaric_heat_capacity / isochoric_heat_capacity) -r""" -:code:`gamma = C_p / C_V` +""" +:laws:symbol:: -Latex: - .. math:: - \gamma = \frac{C_p}{C_V} +:laws:latex:: """ diff --git a/symplyphysics/definitions/impedance_is_resistance_and_reactance.py b/symplyphysics/definitions/impedance_is_resistance_and_reactance.py index 3a28ca3c8..9b56532e3 100644 --- a/symplyphysics/definitions/impedance_is_resistance_and_reactance.py +++ b/symplyphysics/definitions/impedance_is_resistance_and_reactance.py @@ -12,39 +12,28 @@ """ from sympy import (I, Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output) -impedance = Symbol("impedance", units.impedance) +impedance = SymbolNew("Z", units.impedance) """ Impedance of the system. - -Symbol: - :code:`Z` """ -resistance = Symbol("resistance", units.impedance) +resistance = SymbolNew("R", units.impedance) """ Resistance of the system. - -Symbol: - :code:`R` """ -reactance = Symbol("reactance", units.impedance) +reactance = SymbolNew("X", units.impedance) """ Reactance of the system. - -Symbol: - :code:`X` """ definition = Eq(impedance, resistance + I * reactance) """ -:code:`Z = R + i * X` +:laws:symbol:: -Latex: - .. math:: - Z = R + i X +:laws:latex:: """ diff --git a/symplyphysics/definitions/intensity_of_sound_wave_is_rate_of_energy_transfer_over_area.py b/symplyphysics/definitions/intensity_of_sound_wave_is_rate_of_energy_transfer_over_area.py index af432ad51..54208a35a 100644 --- a/symplyphysics/definitions/intensity_of_sound_wave_is_rate_of_energy_transfer_over_area.py +++ b/symplyphysics/definitions/intensity_of_sound_wave_is_rate_of_energy_transfer_over_area.py @@ -10,42 +10,31 @@ from symplyphysics import ( units, Quantity, - Symbol, + SymbolNew, validate_input, validate_output, ) -intensity = Symbol("intensity", units.power / units.area) +intensity = SymbolNew("I", units.power / units.area) """ Intensity of the sound wave. - -Symbol: - :code:`I` """ -power = Symbol("power", units.power) +power = SymbolNew("P", units.power) """ Power, or rate of energy transfer, of the wave. - -Symbol: - :code:`P` """ -area = Symbol("area", units.area) +area = SymbolNew("A", units.area) """ Surface area. - -Symbol: - :code:`A` """ definition = Eq(intensity, power / area) -r""" -:code:`I = P / A` +""" +:laws:symbol:: -Latex: - .. math:: - I = \frac{P}{A} +:laws:latex:: """ diff --git a/symplyphysics/definitions/linear_charge_density_from_charge_and_length.py b/symplyphysics/definitions/linear_charge_density_from_charge_and_length.py index d1d38f1b2..c3623f8a6 100644 --- a/symplyphysics/definitions/linear_charge_density_from_charge_and_length.py +++ b/symplyphysics/definitions/linear_charge_density_from_charge_and_length.py @@ -7,42 +7,28 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output) -linear_charge_density = Symbol("linear_charge_density", units.charge / units.length) -r""" +linear_charge_density = SymbolNew("lambda", units.charge / units.length, display_latex="\\lambda") +""" Linear charge density of the object. - -Symbol: - :code:`lambda` - -Latex: - :math:`\lambda` """ -charge = Symbol("charge", units.charge) +charge = SymbolNew("q", units.charge) """ Charge accumulated in the object. - -Symbol: - :code:`q` """ -length = Symbol("length", units.length) +length = SymbolNew("l", units.length) """ Length of the object. - -Symbol: - :code:`l` """ definition = Eq(linear_charge_density, charge / length) -r""" -:code:`lambda = q / l` +""" +:laws:symbol:: -Latex: - .. math:: - \lambda = \frac{q}{l} +:laws:latex:: """ diff --git a/symplyphysics/definitions/linear_coefficient_of_thermal_expansion.py b/symplyphysics/definitions/linear_coefficient_of_thermal_expansion.py index df2f3ffb0..731280f01 100644 --- a/symplyphysics/definitions/linear_coefficient_of_thermal_expansion.py +++ b/symplyphysics/definitions/linear_coefficient_of_thermal_expansion.py @@ -19,32 +19,23 @@ from symplyphysics import ( units, Quantity, - Symbol, - Function, + SymbolNew, + FunctionNew, validate_input, validate_output, symbols, ) from symplyphysics.core.geometry.line import two_point_function, Point2D -linear_expansion_coefficient = Symbol("linear_expansion_coefficient", 1 / units.temperature) -r""" +linear_expansion_coefficient = SymbolNew("alpha_l", 1 / units.temperature, display_latex="\\alpha_l") +""" Linear coefficient of thermal expansion of the object. - -Symbol: - :code:`alpha_l` - -Latex: - :math:`\alpha_l` """ -length = Function("length", units.length) +length = FunctionNew("l(T, p)", units.length, display_latex="l") """ Length of the object as a function of :attr:`~symplyphysics.symbols.thermodynamics.temperature` and, indirectly, pressure :math:`p`. - -Symbol: - :code:`l(T, p)` """ temperature = symbols.thermodynamics.temperature @@ -57,11 +48,15 @@ Derivative(length(temperature), temperature) / length(temperature), ) r""" -:code:`alpha_l = 1 / l(T, p) * Derivative(l(T, p), T)` +:laws:symbol:: + +.. only:: comment + + Derivatives with one parameter held constant are not very pretty when autogenerated. Latex: .. math:: - \alpha_l = \frac{1}{l(T, p)} \left( \frac{d l}{d T} \right)_p + \alpha_l = \frac{1}{l(T, p)} \left( \frac{\partial l(T, p)}{\partial T} \right)_p """ diff --git a/symplyphysics/definitions/lorentz_factor.py b/symplyphysics/definitions/lorentz_factor.py index 516c76513..2ea97e12b 100644 --- a/symplyphysics/definitions/lorentz_factor.py +++ b/symplyphysics/definitions/lorentz_factor.py @@ -1,53 +1,45 @@ -r""" +""" Lorentz factor ============== *Lorentz factor*, also known as *Lorentz term* or *gamma factor*, is a quantity that expresses how much the measurements of time, length, and other physical properties change for a body while it is moving. - -**Notation:** - -#. :math:`c` is the speed of light. """ from sympy import Eq, sqrt -from sympy.physics.units import speed_of_light from symplyphysics import ( + quantities, units, dimensionless, Quantity, - Symbol, + SymbolNew, validate_input, validate_output, ) -lorentz_factor = Symbol("lorentz_factor", dimensionless) -r""" +lorentz_factor = SymbolNew("gamma", dimensionless, display_latex="\\gamma") +""" Lorentz factor of the body. - -Symbol: - :code:`gamma` - -Latex: - :math:`\gamma` """ -speed = Symbol("speed", units.speed) +speed = SymbolNew("v", units.speed) """ Speed of the body. +""" -Symbol: - :code:`v` +speed_of_light = quantities.speed_of_light +""" +:attr:`~symplyphysics.quantities.speed_of_light` """ +# TODO: use autogenerated representation, but fix (1 / sqrt) code representation before + definition = Eq(lorentz_factor, 1 / sqrt(1 - speed**2 / speed_of_light**2)) -r""" +""" :code:`gamma = 1 / sqrt(1 - (v / c)^2)` -Latex: - .. math:: - \gamma = \frac{1}{\sqrt{1 - \left( \frac{v}{c} \right)^2}} +:laws:latex:: """ diff --git a/symplyphysics/definitions/mass_flow_rate.py b/symplyphysics/definitions/mass_flow_rate.py index 2babe0410..f6a4f27d6 100644 --- a/symplyphysics/definitions/mass_flow_rate.py +++ b/symplyphysics/definitions/mass_flow_rate.py @@ -1,4 +1,4 @@ -r""" +""" Mass flow rate ============== @@ -7,42 +7,28 @@ """ from sympy import (Eq, Derivative) -from symplyphysics import (units, Quantity, Function, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, FunctionNew, SymbolNew, validate_input, validate_output) -mass_flow_rate = Function("mass_flow_rate", units.mass / units.time) -r""" +mass_flow_rate = FunctionNew("mu(t)", units.mass / units.time, display_latex="\\mu") +""" Mass flow rate as a function of time. - -Symbol: - :code:`mu(t)` - -Latex: - :math:`\mu(t)` """ -mass = Function("mass", units.mass) +mass = FunctionNew("m(t)", units.mass, display_latex="m") """ :attr:`~symplyphysics.symbols.basic.mass` as a function of time. - -Symbol: - :code:`m(t)` """ -time = Symbol("time", units.time) +time = SymbolNew("t", units.time) """ Time. - -Symbol: - :code:`t` """ definition = Eq(mass_flow_rate(time), Derivative(mass(time), time)) -r""" -:code:`mu(t) = Derivative(m(t), t)` +""" +:laws:symbol:: -Latex: - .. math:: - \mu(t) = \frac{d m}{d t} +:laws:latex:: """ diff --git a/symplyphysics/definitions/mass_fraction.py b/symplyphysics/definitions/mass_fraction.py index 5aaaa8b89..a6c41b107 100644 --- a/symplyphysics/definitions/mass_fraction.py +++ b/symplyphysics/definitions/mass_fraction.py @@ -8,7 +8,7 @@ from sympy import Eq, solve from symplyphysics import ( Quantity, - Symbol, + SymbolNew, validate_input, validate_output, dimensionless, @@ -18,18 +18,12 @@ ) from symplyphysics.core.symbols.fraction import Fraction -mass_fraction = Symbol("mass_fraction", dimensionless) -r""" +mass_fraction = SymbolNew("w", dimensionless, display_latex="\\omega") +""" Mass fraction of the mixture component. - -Symbol: - :code:`w` - -Latex: - :math:`\omega` """ -mass_of_component = clone_symbol(symbols.basic.mass, display_symbol="m_i", display_latex="m_i") +mass_of_component = clone_symbol(symbols.basic.mass, display_symbol="m[i]", display_latex="m_i") """ :attr:`~symplyphysics.symbols.basic.mass` of the mixture component. """ @@ -40,12 +34,10 @@ """ definition = Eq(mass_fraction, mass_of_component / mass_of_mixture) -r""" -:code:`w = m_i / m` +""" +:laws:symbol:: -Latex: - .. math:: - \omega = \frac{m_i}{m} +:laws:latex:: """ diff --git a/symplyphysics/definitions/mechanical_energy_is_kinetic_and_potential_energy.py b/symplyphysics/definitions/mechanical_energy_is_kinetic_and_potential_energy.py index 5a5c36947..ae6398ad9 100644 --- a/symplyphysics/definitions/mechanical_energy_is_kinetic_and_potential_energy.py +++ b/symplyphysics/definitions/mechanical_energy_is_kinetic_and_potential_energy.py @@ -6,39 +6,28 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output) -mechanical_energy = Symbol("mechanical_energy", units.energy) +mechanical_energy = SymbolNew("E", units.energy) """ Mechanical energy of the system. - -Symbol: - :code:`E` """ -kinetic_energy = Symbol("kinetic_energy", units.energy) +kinetic_energy = SymbolNew("K", units.energy) """ Kinetic energy of the system. - -Symbol: - :code:`K` """ -potential_energy = Symbol("potential_energy", units.energy) +potential_energy = SymbolNew("U", units.energy) """ Potential energy of the system. - -Symbol: - :code:`U` """ definition = Eq(mechanical_energy, kinetic_energy + potential_energy) """ -:code:`E = K + U` +:laws:symbol:: -Latex: - .. math:: - E = K + U +:laws:latex:: """ diff --git a/symplyphysics/definitions/momentum_is_mass_times_speed.py b/symplyphysics/definitions/momentum_is_mass_times_speed.py index 72af4d8c6..d7a66acf4 100644 --- a/symplyphysics/definitions/momentum_is_mass_times_speed.py +++ b/symplyphysics/definitions/momentum_is_mass_times_speed.py @@ -6,22 +6,16 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output, symbols) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output, symbols) -momentum = Symbol("momentum", units.momentum) +momentum = SymbolNew("p", units.momentum) """ Momentum of the object. - -Symbol: - :code:`p` """ -speed = Symbol("speed", units.speed) +speed = SymbolNew("v", units.speed) """ Speed of the object. - -Symbol: - :code:`v` """ mass = symbols.basic.mass @@ -31,11 +25,9 @@ definition = Eq(momentum, mass * speed) """ -:code:`p = m * v` +:laws:symbol:: -Latex: - .. math:: - p = m v +:laws:latex:: """ diff --git a/symplyphysics/definitions/number_density_is_number_of_objects_per_unit_volume.py b/symplyphysics/definitions/number_density_is_number_of_objects_per_unit_volume.py index 0df63d346..29ed57633 100644 --- a/symplyphysics/definitions/number_density_is_number_of_objects_per_unit_volume.py +++ b/symplyphysics/definitions/number_density_is_number_of_objects_per_unit_volume.py @@ -7,39 +7,28 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, dimensionless, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, dimensionless, validate_input, validate_output) -number_density = Symbol("number_density", 1 / units.volume) +number_density = SymbolNew("n", 1 / units.volume) """ Concentration of particles. - -Symbol: - :code:`n` """ -number_of_objects = Symbol("number_of_objects", dimensionless) +number_of_objects = SymbolNew("N", dimensionless) """ Number of particles within the volume. - -Symbol: - :code:`N` """ -volume = Symbol("volume", units.volume) +volume = SymbolNew("V", units.volume) """ Volume in which the particles are located. - -Symbol: - :code:`V` """ definition = Eq(number_density, number_of_objects / volume) -r""" -:code:`n = N / V` +""" +:laws:symbol:: -Latex: - .. math:: - n = \frac{N}{V} +:laws:latex:: """ diff --git a/symplyphysics/definitions/period_from_angular_frequency.py b/symplyphysics/definitions/period_from_angular_frequency.py index 3b7b1c62d..5b23da0a0 100644 --- a/symplyphysics/definitions/period_from_angular_frequency.py +++ b/symplyphysics/definitions/period_from_angular_frequency.py @@ -8,36 +8,25 @@ """ from sympy import (Eq, solve, pi) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output) from symplyphysics.core.expr_comparisons import expr_equals from symplyphysics.laws.kinematics import average_angular_speed_is_angular_distance_over_time as frequency_def -period = Symbol("period", units.time) +period = SymbolNew("T", units.time) """ Period of oscillations. - -Symbol: - :code:`T` """ -angular_frequency = Symbol("angular_frequency", units.frequency) -r""" +angular_frequency = SymbolNew("w", units.frequency, display_latex="\\omega") +""" Angular, or circular, frequency of oscillations. - -Symbol: - :code:`w` - -Latex: - :math:`\omega` """ law = Eq(period, 2 * pi / angular_frequency) -r""" -:code:`T = 2 * pi / w` +""" +:laws:symbol:: -Latex: - .. math:: - T = \frac{2 \pi}{\omega} +:laws:latex:: """ # Derive the same law from angular frequency diff --git a/symplyphysics/definitions/power_is_energy_derivative.py b/symplyphysics/definitions/power_is_energy_derivative.py index d5ba2904d..92257835f 100644 --- a/symplyphysics/definitions/power_is_energy_derivative.py +++ b/symplyphysics/definitions/power_is_energy_derivative.py @@ -1,4 +1,4 @@ -r""" +""" Power is energy derivative ========================== @@ -7,39 +7,28 @@ """ from sympy import (Eq, Derivative) -from symplyphysics import (units, Quantity, Function, Symbol, validate_input, validate_output) +from symplyphysics import (units, Quantity, FunctionNew, SymbolNew, validate_input, validate_output) -power = Function("power", units.power) +power = FunctionNew("P(t)", units.power, display_latex="P") """ Power as a function of time. - -Symbol: - :code:`P(t)` """ -energy = Function("energy", units.energy) +energy = FunctionNew("E(t)", units.energy, display_latex="E") """ Energy as a function of time. - -Symbol: - :code:`E(t)` """ -time = Symbol("time", units.time) +time = SymbolNew("t", units.time) """ Time. - -Symbol: - :code:`t` """ definition = Eq(power(time), Derivative(energy(time), time)) -r""" -:code:`P(t) = Derivative(E(t), t)` +""" +:laws:symbol:: -Latex: - .. math:: - P(t) = \frac{d E}{d t} +:laws:latex:: """ diff --git a/symplyphysics/definitions/quality_factor_is_energies_ratio.py b/symplyphysics/definitions/quality_factor_is_energies_ratio.py index 7f1b7e955..5eaf87beb 100644 --- a/symplyphysics/definitions/quality_factor_is_energies_ratio.py +++ b/symplyphysics/definitions/quality_factor_is_energies_ratio.py @@ -7,51 +7,34 @@ """ from sympy import (Eq, solve) -from symplyphysics import (units, Quantity, Symbol, validate_input, validate_output, dimensionless, +from symplyphysics import (units, Quantity, SymbolNew, validate_input, validate_output, dimensionless, angle_type) -quality_factor = Symbol("quality_factor", dimensionless) +quality_factor = SymbolNew("Q", dimensionless) """ Quality factor of the oscillator. - -Symbol: - :code:`Q` """ -resonant_frequency = Symbol("resonant_frequency", angle_type / units.time) -r""" +resonant_frequency = SymbolNew("w", angle_type / units.time, display_latex="\\omega") +""" Resonant angular frequency of the oscillator. - -Symbol: - :code:`w` - -Latex: - :math:`\omega` """ -stored_energy = Symbol("stored_energy", units.energy) +stored_energy = SymbolNew("E", units.energy) """ Energy stored in the oscillator. - -Symbol: - :code:`E` """ -dissipated_power = Symbol("dissipated_power", units.power) +dissipated_power = SymbolNew("P", units.power) """ Power dissipated from the oscillater. - -Symbol: - :code:`P` """ definition = Eq(quality_factor, resonant_frequency * stored_energy / dissipated_power) -r""" -:code:`Q = w * E / P` +""" +:laws:symbol:: -Latex: - .. math:: - Q = \frac{\omega E}{P} +:laws:latex:: """ diff --git a/symplyphysics/definitions/radiant_exitance_is_radiant_flux_emitted_per_unit_area.py b/symplyphysics/definitions/radiant_exitance_is_radiant_flux_emitted_per_unit_area.py index 4372b10a9..8f176916d 100644 --- a/symplyphysics/definitions/radiant_exitance_is_radiant_flux_emitted_per_unit_area.py +++ b/symplyphysics/definitions/radiant_exitance_is_radiant_flux_emitted_per_unit_area.py @@ -1,4 +1,4 @@ -r""" +""" Radiant exitance is radiant flux emitted per unit area ====================================================== @@ -13,49 +13,32 @@ from symplyphysics import ( units, Quantity, - Symbol, - Function, + SymbolNew, + FunctionNew, validate_input, validate_output, ) -radiant_exitance = Symbol("radiant_exitance", units.power / units.area) +radiant_exitance = SymbolNew("M_e", units.power / units.area) """ Radiant exitance of the surface. - -Symbol: - :code:`M_e` - -Latex: - :math:`M_e` """ -radiant_flux = Function("radiant_flux", units.power) -r""" +radiant_flux = FunctionNew("Phi_e(A)", units.power, display_latex="\\Phi_e") +""" Radiant flux, or radiant power, emitted from the surface. - -Symbol: - :code:`Phi_e(A)` - -Latex: - :math:`\Phi_e(A)` """ -area = Symbol("area", units.area) +area = SymbolNew("A", units.area) """ The area of the surface. - -Symbol: - :code:`A` """ definition = Eq(radiant_exitance, Derivative(radiant_flux(area), area)) -r""" -:code:`M_e = Derivative(Phi_e(A), A)` +""" +:laws:symbol:: -Latex: - .. math:: - M_e = \frac{\partial \Phi_e}{\partial A} +:laws:latex:: """ diff --git a/symplyphysics/docs/printer_code.py b/symplyphysics/docs/printer_code.py index b41b3b21c..d072337ed 100644 --- a/symplyphysics/docs/printer_code.py +++ b/symplyphysics/docs/printer_code.py @@ -15,6 +15,7 @@ class SymbolCodePrinter(StrPrinter): """ def __init__(self, settings: Any = None) -> None: + settings["order"] = "lex" StrPrinter.__init__(self, settings) # pylint: disable-next=invalid-name diff --git a/symplyphysics/docs/printer_latex.py b/symplyphysics/docs/printer_latex.py index 4a0543aab..3fc8d2eb4 100644 --- a/symplyphysics/docs/printer_latex.py +++ b/symplyphysics/docs/printer_latex.py @@ -15,6 +15,7 @@ class SymbolLatexPrinter(LatexPrinter): language = "Symplyphysics" def __init__(self, settings: Any = None) -> None: + settings["order"] = "lex" LatexPrinter.__init__(self, settings) # pylint: disable-next=invalid-name @@ -112,6 +113,17 @@ def _print_Function(self, expr: Any, exp: Any = None) -> str: return name % ",".join(args) + # TODO: use e^ for shorter expressions + def _print_ExpBase(self, expr: Any, exp: Any = None) -> str: + args = [str(self._print(arg)) for arg in expr.args] + can_fold_brackets = self._settings["fold_func_brackets"] and \ + len(args) == 1 and \ + not self._needs_function_brackets(expr.args[0]) + args_str = self._print(expr.args[0]) + name = f"{args_str}" if can_fold_brackets else f"\\left({args_str} \\right)" + tex = r"exp{%s}" % name + return self._do_exponent(tex, exp) + # pylint: disable-next=invalid-name def _print_SumIndexed(self, expr: Any) -> str: # only one index of sum is supported diff --git a/symplyphysics/laws/dynamics/work_is_integral_of_force_over_distance.py b/symplyphysics/laws/dynamics/work_is_integral_of_force_over_distance.py index f12bb9896..96e0bc91c 100644 --- a/symplyphysics/laws/dynamics/work_is_integral_of_force_over_distance.py +++ b/symplyphysics/laws/dynamics/work_is_integral_of_force_over_distance.py @@ -31,7 +31,7 @@ """ force = Function("force", units.force) -r""" +""" The :attr:`~symplyphysics.symbols.dynamics.force` exerted on the object as a function of position. Symbol: @@ -39,7 +39,7 @@ """ position = Symbol("position", units.length) -r""" +""" The position of the object. Symbol: @@ -47,7 +47,7 @@ """ position_before = Symbol("position_before", units.length) -r""" +""" The initial position of the object. Symbol: @@ -58,7 +58,7 @@ """ position_after = Symbol("position_after", units.length) -r""" +""" The end position of the object. Symbol: diff --git a/symplyphysics/laws/electricity/current_is_voltage_over_resistance.py b/symplyphysics/laws/electricity/current_is_voltage_over_resistance.py index 758a0b745..c590a1153 100644 --- a/symplyphysics/laws/electricity/current_is_voltage_over_resistance.py +++ b/symplyphysics/laws/electricity/current_is_voltage_over_resistance.py @@ -27,7 +27,7 @@ """ resistance = Symbol("resistance", units.impedance) -r""" +""" Resistance of the conductor. Symbol: diff --git a/symplyphysics/laws/electricity/electric_charge_is_constant_in_isolated_system.py b/symplyphysics/laws/electricity/electric_charge_is_constant_in_isolated_system.py index 6d1c1e445..0d6b33ed9 100644 --- a/symplyphysics/laws/electricity/electric_charge_is_constant_in_isolated_system.py +++ b/symplyphysics/laws/electricity/electric_charge_is_constant_in_isolated_system.py @@ -11,22 +11,22 @@ validate_output) initial_charge = Symbol("initial_charge", units.charge) -r""" +""" Initial charge of the system. Symbol: - :code:`q_0` + :code:`q0` Latex: - :math:`q_1` + :math:`q_0` """ final_charge = Symbol("final_charge", units.charge) -r""" +""" Final charge of the system. Symbol: - :code:`q_1` + :code:`q1` Latex: :math:`q_1` @@ -34,7 +34,7 @@ law = Eq(final_charge, initial_charge) r""" -:code:`q_0 = q_1` +:code:`q0 = q1` Latex: .. math:: diff --git a/symplyphysics/laws/electricity/electric_field_is_force_over_test_charge.py b/symplyphysics/laws/electricity/electric_field_is_force_over_test_charge.py index 51517c1c1..e9421cc8b 100644 --- a/symplyphysics/laws/electricity/electric_field_is_force_over_test_charge.py +++ b/symplyphysics/laws/electricity/electric_field_is_force_over_test_charge.py @@ -29,15 +29,15 @@ electrostatic_force = clone_symbol(symbols.dynamics.force) """ -Projection of the electrostatic force applied to the test charge. +Projection of the electrostatic :attr:`~symplyphysics.symbols.dynamics.force` applied to the test charge. """ test_charge = Symbol("test_charge", units.charge) -r""" +""" Value of the test charge. Symbol: - :code:`q_0` + :code:`q0` Latex: :math:`q_0` @@ -45,7 +45,7 @@ law = Eq(electric_field_strength, electrostatic_force / test_charge) r""" -:code:`E = F / q_0` +:code:`E = F / q0` Latex: .. math:: diff --git a/symplyphysics/laws/electricity/electrostatic_force_via_charges_and_distance.py b/symplyphysics/laws/electricity/electrostatic_force_via_charges_and_distance.py index c92a71e1a..99b9c0108 100644 --- a/symplyphysics/laws/electricity/electrostatic_force_via_charges_and_distance.py +++ b/symplyphysics/laws/electricity/electrostatic_force_via_charges_and_distance.py @@ -17,29 +17,26 @@ electrostatic_force = clone_symbol(symbols.dynamics.force) """ -Electrostatic force between two charges. - -Symbol: - :code:`F` +Electrostatic :attr:`~symplyphysics.symbols.dynamics.force` between two charges. """ first_charge = Symbol("first_charge", units.charge) -r""" +""" First charge. Symbol: - :code:`q_1` + :code:`q1` Latex: :math:`q_1` """ second_charge = Symbol("second_charge", units.charge) -r""" +""" Second charge. Symbol: - :code:`q_2` + :code:`q2` Latex: :math:`q_2` @@ -56,7 +53,7 @@ law = Eq(electrostatic_force, 1 / (4 * pi * units.vacuum_permittivity) * first_charge * second_charge / (distance**2)) r""" -:code:`F = 1 / (4 * pi * epsilon_0) * q_1 * q_2 / r^2` +:code:`F = 1 / (4 * pi * epsilon_0) * q1 * q2 / r^2` Latex: .. math:: diff --git a/symplyphysics/laws/electricity/electrostatic_potential_energy_of_two_charges_via_distance.py b/symplyphysics/laws/electricity/electrostatic_potential_energy_of_two_charges_via_distance.py index 39ba7cc56..c7a546e46 100644 --- a/symplyphysics/laws/electricity/electrostatic_potential_energy_of_two_charges_via_distance.py +++ b/symplyphysics/laws/electricity/electrostatic_potential_energy_of_two_charges_via_distance.py @@ -47,22 +47,22 @@ """ first_charge = Symbol("first_charge", units.charge) -r""" +""" Value of the first charge. Symbol: - :code:`q_1` + :code:`q1` Latex: :math:`q_1` """ second_charge = Symbol("second_charge", units.charge) -r""" +""" Value of the second charge. Symbol: - :code:`q_2` + :code:`q2` Latex: :math:`q_2` @@ -71,7 +71,7 @@ law = Eq(electrostatic_potential_energy, (first_charge * second_charge) / (4 * pi * absolute_permittivity * distance)) r""" -:code:`U_E = q_1 * q_2 / (4 * pi * epsilon * r)` +:code:`U_E = q1 * q2 / (4 * pi * epsilon * r)` Latex: .. math:: diff --git a/symplyphysics/laws/electricity/magnetic_field_due_to_infinite_wire.py b/symplyphysics/laws/electricity/magnetic_field_due_to_infinite_wire.py index 66f1bf03b..610a32c79 100644 --- a/symplyphysics/laws/electricity/magnetic_field_due_to_infinite_wire.py +++ b/symplyphysics/laws/electricity/magnetic_field_due_to_infinite_wire.py @@ -1,4 +1,4 @@ -""" +r""" Magnetic field due to infinite wire =================================== diff --git a/symplyphysics/laws/electricity/magnetic_field_of_coil.py b/symplyphysics/laws/electricity/magnetic_field_of_coil.py index e3c1d782c..03d58a159 100644 --- a/symplyphysics/laws/electricity/magnetic_field_of_coil.py +++ b/symplyphysics/laws/electricity/magnetic_field_of_coil.py @@ -1,4 +1,4 @@ -""" +r""" Magnetic field of coil ====================== diff --git a/symplyphysics/laws/electricity/period_of_rotation_of_charged_particle_in_magnetic_field.py b/symplyphysics/laws/electricity/period_of_rotation_of_charged_particle_in_magnetic_field.py index db6da964e..6b8c5c279 100644 --- a/symplyphysics/laws/electricity/period_of_rotation_of_charged_particle_in_magnetic_field.py +++ b/symplyphysics/laws/electricity/period_of_rotation_of_charged_particle_in_magnetic_field.py @@ -30,9 +30,6 @@ mass = symbols.basic.mass """ :attr:`~symplyphysics.symbols.basic.mass` of the particle. - -Symbol: - :code:`m` """ charge = Symbol("charge", units.charge) diff --git a/symplyphysics/laws/electricity/radius_of_curvature_of_charged_particle_in_magnetic_field.py b/symplyphysics/laws/electricity/radius_of_curvature_of_charged_particle_in_magnetic_field.py index 6df0fc7e0..5b923c9c7 100644 --- a/symplyphysics/laws/electricity/radius_of_curvature_of_charged_particle_in_magnetic_field.py +++ b/symplyphysics/laws/electricity/radius_of_curvature_of_charged_particle_in_magnetic_field.py @@ -39,9 +39,6 @@ mass = symbols.basic.mass """ :attr:`~symplyphysics.symbols.basic.mass` of the particle. - -Symbol: - :code:`m` """ speed = Symbol("speed", units.speed) diff --git a/symplyphysics/laws/electricity/vector/electric_field_is_force_over_test_charge.py b/symplyphysics/laws/electricity/vector/electric_field_is_force_over_test_charge.py index 2386a9540..84adef115 100644 --- a/symplyphysics/laws/electricity/vector/electric_field_is_force_over_test_charge.py +++ b/symplyphysics/laws/electricity/vector/electric_field_is_force_over_test_charge.py @@ -22,7 +22,7 @@ Value of the test charge. Symbol: - :code:`q_0` + :code:`q0` Latex: :math:`q_0` @@ -34,7 +34,7 @@ def electric_field_law(electrostatic_force_: Vector) -> Vector: Electric field via electrostatic force. Law: - :code:`E = F / q_0` + :code:`E = F / q0` Latex: .. math:: @@ -65,7 +65,7 @@ def electrostatic_force_law(electric_field_: Vector) -> Vector: Electrostatic force via electric field. Law: - :code:`F = q_0 * E` + :code:`F = q0 * E` Latex: .. math:: diff --git a/symplyphysics/laws/electricity/vector/lorentz_force_via_electromagnetic_field.py b/symplyphysics/laws/electricity/vector/lorentz_force_via_electromagnetic_field.py index 6938ec9a5..44370b259 100644 --- a/symplyphysics/laws/electricity/vector/lorentz_force_via_electromagnetic_field.py +++ b/symplyphysics/laws/electricity/vector/lorentz_force_via_electromagnetic_field.py @@ -136,7 +136,7 @@ def electric_field_law( Latex: :math:`\vec B` - Dimension: *magnetic flux density* + Dimension: *magnetic density* :param velocity\_: vector of particle's velocity @@ -206,7 +206,7 @@ def charge_law( Latex: :math:`\vec B` - Dimension: *magnetic flux density* + Dimension: *magnetic density* :param velocity\_: vector of particle's velocity diff --git a/symplyphysics/laws/gravity/planet_period_squared_is_proportional_to_cube_of_semimajor_axis.py b/symplyphysics/laws/gravity/planet_period_squared_is_proportional_to_cube_of_semimajor_axis.py index 652a3b8b6..8aca6ffd2 100644 --- a/symplyphysics/laws/gravity/planet_period_squared_is_proportional_to_cube_of_semimajor_axis.py +++ b/symplyphysics/laws/gravity/planet_period_squared_is_proportional_to_cube_of_semimajor_axis.py @@ -66,10 +66,8 @@ # If the eccentricity of the planet's orbit is not too big, which is the case for most # planets of the solar system, we can substitute the radius with the semi-major axis of # the orbit. -_period_derived = period_law.law.rhs.subs({ - period_law.angular_frequency: _angular_speed_expr, - _radius: semimajor_axis, -}) +_period_derived = period_law.law.rhs.subs(period_law.angular_frequency, _angular_speed_expr) +_period_derived = _period_derived.subs(_radius, semimajor_axis) _period_from_law = solve(law, rotation_period)[0] diff --git a/symplyphysics/laws/gravity/radial_motion/radial_kinetic_energy_plus_potential_energy_is_constant.py b/symplyphysics/laws/gravity/radial_motion/radial_kinetic_energy_plus_potential_energy_is_constant.py index 0100ea4d5..d292b187b 100644 --- a/symplyphysics/laws/gravity/radial_motion/radial_kinetic_energy_plus_potential_energy_is_constant.py +++ b/symplyphysics/laws/gravity/radial_motion/radial_kinetic_energy_plus_potential_energy_is_constant.py @@ -27,7 +27,7 @@ """ radial_speed = Symbol("radial_speed", units.velocity) -r""" +""" The projection of the velocity vector in the radial direction. Symbol: diff --git a/symplyphysics/laws/hydro/surface_tension_force_via_surface_tension_and_length.py b/symplyphysics/laws/hydro/surface_tension_force_via_surface_tension_and_length.py index 5f345021d..b171d3d96 100644 --- a/symplyphysics/laws/hydro/surface_tension_force_via_surface_tension_and_length.py +++ b/symplyphysics/laws/hydro/surface_tension_force_via_surface_tension_and_length.py @@ -35,7 +35,7 @@ """ length = Symbol("length", units.length) -r""" +""" Length of the contour to which the force is applied. Symbol: diff --git a/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_critical_damping.py b/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_critical_damping.py index 042767533..189bee58b 100644 --- a/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_critical_damping.py +++ b/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_critical_damping.py @@ -54,22 +54,22 @@ """ initial_position = Symbol("initial_position", units.length, real=True) -r""" +""" Initial position of the oscillator. Symbol: - :code:`x_0` + :code:`x0` Latex: :math:`x_0` """ initial_speed = Symbol("initial_speed", units.velocity, real=True) -r""" +""" Initial speed of the oscillator. Symbol: - :code:`v_0` + :code:`v0` Latex: :math:`v_0` @@ -81,7 +81,7 @@ (initial_speed + initial_position * undamped_angular_frequency) * time), ) r""" -:code:`q = exp(-1 * w * t) * (x_0 + (v_0 + x_0 * w) * t)` +:code:`q = exp(-1 * w * t) * (x0 + (v0 + x0 * w) * t)` Latex: .. math:: diff --git a/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_underdamping.py b/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_underdamping.py index 62b33f791..d53fe0960 100644 --- a/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_underdamping.py +++ b/symplyphysics/laws/kinematics/damped_oscillations/displacement_in_underdamping.py @@ -131,7 +131,7 @@ damped_eqn.damping_ratio: _damping_ratio_expr, }).doit() -assert expr_equals(_diff_eqn_subs, 0) +assert expr_equals(_diff_eqn_subs.lhs, _diff_eqn_subs.rhs) @validate_input( diff --git a/symplyphysics/laws/kinematics/position_via_constant_acceleration_and_time.py b/symplyphysics/laws/kinematics/position_via_constant_acceleration_and_time.py index 8a046a7f7..1fb1cfa17 100644 --- a/symplyphysics/laws/kinematics/position_via_constant_acceleration_and_time.py +++ b/symplyphysics/laws/kinematics/position_via_constant_acceleration_and_time.py @@ -16,7 +16,7 @@ from symplyphysics.definitions import acceleration_is_speed_derivative as _acceleration_definition final_position = Symbol("final_position", units.length) -r""" +""" Position at time :math:`t`. Symbol: @@ -24,22 +24,25 @@ """ initial_position = Symbol("initial_position", units.length) -r""" +""" Position at :math:`t = 0`. Symbol: - :code:`x_0` + :code:`x0` Latex: :math:`x_0` """ initial_speed = Symbol("initial_speed", units.velocity) -r""" +""" Speed at :math:`t = 0`. Symbol: - :code:`v_0` + :code:`v0` + +Latex: + :math:`v_0` """ acceleration = symbols.kinematics.acceleration @@ -48,7 +51,7 @@ """ time = Symbol("time", units.time) -r""" +""" Time at which :math:`x` is measured. Symbol: @@ -57,7 +60,7 @@ law = Eq(final_position, initial_position + initial_speed * time + acceleration * time**2 / 2) r""" -:code:`x = x_0 + v_0 * t + (1/2) * a * t^2` +:code:`x = x0 + v0 * t + (1/2) * a * t^2` Latex: .. math:: diff --git a/symplyphysics/laws/kinematics/position_via_constant_speed_and_time.py b/symplyphysics/laws/kinematics/position_via_constant_speed_and_time.py index 77e3ef0d8..4130d0f36 100644 --- a/symplyphysics/laws/kinematics/position_via_constant_speed_and_time.py +++ b/symplyphysics/laws/kinematics/position_via_constant_speed_and_time.py @@ -16,7 +16,7 @@ from symplyphysics.definitions import speed_is_distance_derivative as velocity_definition final_position = Symbol("distance_function", units.length) -r""" +""" Position at time :math:`t`. Symbol: @@ -24,11 +24,11 @@ """ initial_position = Symbol("initial_position", units.length) -r""" +""" Position at :math:`t = 0`. Symbol: - :code:`x_0` + :code:`x0` Latex: :math:`x_0` @@ -43,7 +43,7 @@ """ time = Symbol("time", units.time) -r""" +""" Time at which :math:`x` is measured. Symbol: @@ -52,7 +52,7 @@ law = Eq(final_position, initial_position + speed * time) r""" -:code:`x = x_0 + v * t` +:code:`x = x0 + v * t` Latex: .. math:: diff --git a/symplyphysics/laws/kinematics/speed_via_constant_acceleration_and_time.py b/symplyphysics/laws/kinematics/speed_via_constant_acceleration_and_time.py index a88eb0095..a075bafec 100644 --- a/symplyphysics/laws/kinematics/speed_via_constant_acceleration_and_time.py +++ b/symplyphysics/laws/kinematics/speed_via_constant_acceleration_and_time.py @@ -35,11 +35,11 @@ """ initial_speed = Symbol("initial_speed", units.velocity) -r""" +""" Speed at :math:`t = 0`. Symbol: - :code:`v_0` + :code:`v0` Latex: :math:`v_0` @@ -47,7 +47,7 @@ law = Eq(final_speed, initial_speed + acceleration * time) r""" -:code:`v = v_0 + a * t` +:code:`v = v0 + a * t` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/change_in_entropy_of_ideal_gas_from_volume_and_temperature.py b/symplyphysics/laws/thermodynamics/change_in_entropy_of_ideal_gas_from_volume_and_temperature.py index 4861552c6..e31506e9d 100644 --- a/symplyphysics/laws/thermodynamics/change_in_entropy_of_ideal_gas_from_volume_and_temperature.py +++ b/symplyphysics/laws/thermodynamics/change_in_entropy_of_ideal_gas_from_volume_and_temperature.py @@ -55,14 +55,14 @@ """ final_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_1", + display_symbol="T1", display_latex="T_1") """ :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the final state. """ initial_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_0", + display_symbol="T0", display_latex="T_0") """ :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the initial state. @@ -73,7 +73,7 @@ Volume of the final state. Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` @@ -84,7 +84,7 @@ Volume of the initial state. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` @@ -94,7 +94,7 @@ ((molar_isochoric_heat_capacity * log(final_temperature / initial_temperature)) + (units.molar_gas_constant * log(final_volume / initial_volume)))) r""" -:code:`S = (m / M) * (C_V * log(T_1 / T_0) + R * log(V_1 / V_0))` +:code:`S = (m / M) * (C_V * log(T1 / T0) + R * log(V1 / V0))` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/dynamic_viscosity_of_gas_from_control_viscosity_and_temperature.py b/symplyphysics/laws/thermodynamics/dynamic_viscosity_of_gas_from_control_viscosity_and_temperature.py index e02c9130d..90dbb72df 100644 --- a/symplyphysics/laws/thermodynamics/dynamic_viscosity_of_gas_from_control_viscosity_and_temperature.py +++ b/symplyphysics/laws/thermodynamics/dynamic_viscosity_of_gas_from_control_viscosity_and_temperature.py @@ -47,7 +47,7 @@ """ reference_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_0", + display_symbol="T0", display_latex="T_0") """ :attr:`~symplyphysics.symbols.thermodynamics.temperature` at which the reference viscosity value is calculated. @@ -66,7 +66,7 @@ reference_dynamic_viscosity * ((reference_temperature + sutherland_constant) / (temperature + sutherland_constant)) * (temperature / reference_temperature)**1.5) r""" -:code:`mu = mu_0 * ((T_0 + C) / (T + C)) * (T / T_0)^(3/2)` +:code:`mu = mu_0 * ((T0 + C) / (T + C)) * (T / T0)^(3/2)` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/gas_pressure_change_from_temperature.py b/symplyphysics/laws/thermodynamics/gas_pressure_change_from_temperature.py index a95246b4f..27f0a4452 100644 --- a/symplyphysics/laws/thermodynamics/gas_pressure_change_from_temperature.py +++ b/symplyphysics/laws/thermodynamics/gas_pressure_change_from_temperature.py @@ -36,11 +36,11 @@ """ initial_pressure = Symbol("initial_pressure", units.pressure) -r""" +""" Pressure at :attr:`standard conditions `. Symbol: - :code:`p_0` + :code:`p0` Latex: :math:`p_0` @@ -65,7 +65,7 @@ law = Eq(pressure_change, initial_pressure * (thermal_coefficient * final_temperature - 1)) r""" -:code:`dp = p_0 * (beta_V * T - 1)` +:code:`dp = p0 * (beta_V * T - 1)` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/pressure_and_temperature_in_isochoric_process.py b/symplyphysics/laws/thermodynamics/pressure_and_temperature_in_isochoric_process.py index aaf950676..ce21f557e 100644 --- a/symplyphysics/laws/thermodynamics/pressure_and_temperature_in_isochoric_process.py +++ b/symplyphysics/laws/thermodynamics/pressure_and_temperature_in_isochoric_process.py @@ -17,36 +17,36 @@ from symplyphysics.laws.thermodynamics.equations_of_state import ideal_gas_equation as thermodynamics_law initial_pressure = Symbol("initial_pressure", units.pressure) -r""" +""" Initial pressure of the gas. Symbol: - :code:`p_0` + :code:`p0` Latex: :math:`p_0` """ final_pressure = Symbol("final_pressure", units.pressure) -r""" +""" Final pressure of the gas. Symbol: - :code:`p_1` + :code:`p1` Latex: :math:`p_1` """ initial_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_0", + display_symbol="T0", display_latex="T_0") """ Initial :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the gas. """ final_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_1", + display_symbol="T1", display_latex="T_1") """ Final :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the gas. @@ -54,7 +54,7 @@ law = Eq(initial_pressure / final_pressure, initial_temperature / final_temperature) r""" -:code:`p_0 / p_1 = T_0 / T_1` +:code:`p0 / p1 = T0 / T1` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/pressure_and_volume_in_adiabatic_process.py b/symplyphysics/laws/thermodynamics/pressure_and_volume_in_adiabatic_process.py index 75be58bde..b0e8fef3d 100644 --- a/symplyphysics/laws/thermodynamics/pressure_and_volume_in_adiabatic_process.py +++ b/symplyphysics/laws/thermodynamics/pressure_and_volume_in_adiabatic_process.py @@ -34,58 +34,58 @@ # Some of the following parameters depend on each other. It is up to user which to choose as known. initial_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_0", + display_symbol="T0", display_latex="T_0") """ Initial :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the system. """ final_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_1", + display_symbol="T1", display_latex="T_1") """ Final :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the system. """ initial_volume = Symbol("initial_volume", units.volume) -r""" +""" Initial volume of the system. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` """ final_volume = Symbol("final_volume", units.volume) -r""" +""" Final volume of the system. Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` """ initial_pressure = Symbol("initial_pressure", units.pressure) -r""" +""" Initial pressure inside the system. Symbol: - :code:`p_0` + :code:`p0` Latex: :math:`p_0` """ final_pressure = Symbol("final_pressure", units.pressure) -r""" +""" Final pressure inside the system. Symbol: - :code:`p_1` + :code:`p1` Latex: :math:`p_1` @@ -96,7 +96,7 @@ final_pressure * (final_volume**adiabatic_index), ) r""" -:code:`p_0 * V_0^gamma = p_1 * V_1^gamma` +:code:`p0 * V0^gamma = p1 * V1^gamma` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/pressure_and_volume_in_isothermal_process.py b/symplyphysics/laws/thermodynamics/pressure_and_volume_in_isothermal_process.py index c36b3d35a..ae500de45 100644 --- a/symplyphysics/laws/thermodynamics/pressure_and_volume_in_isothermal_process.py +++ b/symplyphysics/laws/thermodynamics/pressure_and_volume_in_isothermal_process.py @@ -12,44 +12,44 @@ from symplyphysics.laws.thermodynamics.equations_of_state import ideal_gas_equation as thermodynamics_law initial_pressure = Symbol("initial_pressure", units.pressure) -r""" +""" Initial pressure inside the system. Symbol: - :code:`p_0` + :code:`p0` Latex: :math:`p_0` """ final_pressure = Symbol("final_pressure", units.pressure) -r""" +""" Final pressure inside the system. Symbol: - :code:`p_1` + :code:`p1` Latex: :math:`p_1` """ initial_volume = Symbol("initial_volume", units.volume) -r""" +""" Initial volume of the system. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` """ final_volume = Symbol("final_volume", units.volume) -r""" +""" Final volume of the system. Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` @@ -57,7 +57,7 @@ law = Eq(initial_pressure * initial_volume, final_pressure * final_volume) r""" -:code:`p_0 * V_0 = p_1 * V_1` +:code:`p0 * V0 = p1 * V1` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/pressure_of_ideal_gas_from_height_and_temperature.py b/symplyphysics/laws/thermodynamics/pressure_of_ideal_gas_from_height_and_temperature.py index 5434ac1f8..35ac64a2d 100644 --- a/symplyphysics/laws/thermodynamics/pressure_of_ideal_gas_from_height_and_temperature.py +++ b/symplyphysics/laws/thermodynamics/pressure_of_ideal_gas_from_height_and_temperature.py @@ -28,11 +28,11 @@ """ initial_pressure = Symbol("initial_pressure", units.pressure) -r""" +""" Pressure of the gas at initial height. Symbol: - :code:`p_0` + :code:`p0` Latex: :math:`p_0` @@ -64,7 +64,7 @@ initial_pressure * exp(-units.acceleration_due_to_gravity * molecular_mass * height_change / (units.boltzmann_constant * temperature))) r""" -:code:`p = p_0 * exp(-1 * g * m * dh / (k_B * T))` +:code:`p = p0 * exp(-1 * g * m * dh / (k_B * T))` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/probability_of_finding_ideal_gas_molecules_in_volume.py b/symplyphysics/laws/thermodynamics/probability_of_finding_ideal_gas_molecules_in_volume.py index 59ba0f073..467a878cf 100644 --- a/symplyphysics/laws/thermodynamics/probability_of_finding_ideal_gas_molecules_in_volume.py +++ b/symplyphysics/laws/thermodynamics/probability_of_finding_ideal_gas_molecules_in_volume.py @@ -25,7 +25,7 @@ from symplyphysics.core.symbols.probability import Probability probability = Symbol("probability", dimensionless) -r""" +""" Probability of finding :math:`N` gas particles in volume :math:`V`. Symbol: @@ -33,11 +33,11 @@ """ total_volume = Symbol("total_volume", units.volume) -r""" +""" Total volume of the region. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` @@ -52,7 +52,7 @@ """ particle_count = Symbol("particle_count", dimensionless, integer=True) -r""" +""" Number of gas particles in :math:`V`. Symbol: @@ -61,7 +61,7 @@ law = Eq(probability, (partial_volume / total_volume)**particle_count) r""" -:code:`P = (V / V_0)^N` +:code:`P = (V / V0)^N` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/volume_and_temperature_in_isobaric_process.py b/symplyphysics/laws/thermodynamics/volume_and_temperature_in_isobaric_process.py index d2a9ec4bd..b0ef9ad4f 100644 --- a/symplyphysics/laws/thermodynamics/volume_and_temperature_in_isobaric_process.py +++ b/symplyphysics/laws/thermodynamics/volume_and_temperature_in_isobaric_process.py @@ -13,36 +13,36 @@ from symplyphysics.laws.thermodynamics.equations_of_state import ideal_gas_equation as thermodynamics_law initial_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_0", + display_symbol="T0", display_latex="T_0") """ Initial :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the system. """ final_temperature = clone_symbol(symbols.thermodynamics.temperature, - display_symbol="T_1", + display_symbol="T1", display_latex="T_1") """ Final :attr:`~symplyphysics.symbols.thermodynamics.temperature` of the system. """ initial_volume = Symbol("initial_volume", units.volume) -r""" +""" Initial volume of the system. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` """ final_volume = Symbol("final_volume", units.volume) -r""" +""" Final volume of the system. Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` @@ -50,7 +50,7 @@ law = Eq(initial_volume / final_volume, initial_temperature / final_temperature) r""" -:code:`V_0 / V_1 = T_0 / T_1` +:code:`V0 / V1 = T0 / T1` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/work_is_integral_of_pressure_over_volume.py b/symplyphysics/laws/thermodynamics/work_is_integral_of_pressure_over_volume.py index b9d158b76..0b9be1646 100644 --- a/symplyphysics/laws/thermodynamics/work_is_integral_of_pressure_over_volume.py +++ b/symplyphysics/laws/thermodynamics/work_is_integral_of_pressure_over_volume.py @@ -49,22 +49,22 @@ """ initial_volume = Symbol("initial_volume", units.volume) -r""" +""" Initial volume of the system. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` """ final_volume = Symbol("final_volume", units.volume) -r""" +""" Final volume of the system. Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` @@ -72,7 +72,7 @@ law = Eq(work, Integral(pressure(volume), (volume, initial_volume, final_volume))) r""" -:code:`W = Integral(p(V), (V, V_0, V_1))` +:code:`W = Integral(p(V), (V, V0, V1))` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isobaric_process.py b/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isobaric_process.py index 8e7b5cbaa..ab9ee599b 100644 --- a/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isobaric_process.py +++ b/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isobaric_process.py @@ -32,22 +32,22 @@ """ initial_volume = Symbol("initial_volume", units.volume) -r""" +""" Initial volume of the gas. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` """ final_volume = Symbol("final_volume", units.volume) -r""" +""" Final volume of the gas Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` @@ -55,7 +55,7 @@ law = Eq(work, pressure * (final_volume - initial_volume)) r""" -:code:`W = p * (V_1 - V_0)` +:code:`W = p * (V1 - V0)` Latex: .. math:: diff --git a/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isothermal_process.py b/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isothermal_process.py index 134d3d3e4..8b9dfa304 100644 --- a/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isothermal_process.py +++ b/symplyphysics/laws/thermodynamics/work_of_ideal_gas_in_isothermal_process.py @@ -46,11 +46,11 @@ """ initial_volume = Symbol("initial_volume", units.volume) -r""" +""" Initial volume of the gas. Symbol: - :code:`V_0` + :code:`V0` Latex: :math:`V_0` @@ -61,7 +61,7 @@ Final volume of the gas. Symbol: - :code:`V_1` + :code:`V1` Latex: :math:`V_1` @@ -77,7 +77,7 @@ amount_of_substance * units.molar_gas_constant * temperature * log(final_volume / initial_volume)) r""" -:code:`W = n * R * T * log(V_1 / V_0)` +:code:`W = n * R * T * log(V1 / V0)` Latex: .. math:: diff --git a/symplyphysics/quantities/__init__.py b/symplyphysics/quantities/__init__.py index 36fc49a11..b914e1567 100644 --- a/symplyphysics/quantities/__init__.py +++ b/symplyphysics/quantities/__init__.py @@ -60,6 +60,24 @@ Earth. The relative uncertainty of the measurement is :math:`10^{-4}`. """ +boltzmann_constant = Quantity(units.boltzmann_constant, display_symbol="k_B", display_latex="k_\\text{B}") +""" +The Boltzmann constant is the proportionality factor that relates the average relative thermal energy of particles +in a gas with the thermodynamic temperature of the gas. +""" + +molar_gas_constant = Quantity(units.molar_gas_constant, display_symbol="R") +""" +The gas constant is the constant of proportionality that relates the energy scale in physics to the temperature +scale and the scale used for amount of substance. +It is molar equivalent to the :attr:`~symplyphysics.quantities.boltzmann_constant` +""" + +speed_of_light = Quantity(units.speed_of_light, display_symbol="c") +""" +The speed of light in vacuum is a universal physical constant that is exactly equal to 299,792,458 metres per second. +""" + __all__ = [ "standard_conditions_temperature", "standard_laboratory_temperature", @@ -68,4 +86,7 @@ "hydrogen_ionization_energy", "solar_mass", "earth_mass", + "boltzmann_constant", + "molar_gas_constant", + "speed_of_light", ]