Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numerical error on conversion of coulomb to statcoulomb #24325

Merged
merged 10 commits into from
Dec 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix # 24319
  • Loading branch information
1e9abhi1e10 committed Nov 29, 2022
commit dad762aba0cec8620f0107d45fe38ecf6b1a756a
35 changes: 19 additions & 16 deletions sympy/physics/units/tests/test_unit_system_cgs_gauss.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,29 @@


def test_conversion_to_from_si():

assert convert_to(statcoulomb, coulomb, cgs_gauss) == coulomb/2997924580
assert convert_to(coulomb, statcoulomb, cgs_gauss) == 2997924580*statcoulomb
assert convert_to(statcoulomb, sqrt(gram*centimeter**3)/second, cgs_gauss) == centimeter**(S(3)/2)*sqrt(gram)/second
assert convert_to(coulomb, sqrt(gram*centimeter**3)/second, cgs_gauss) == 149896229*centimeter**(S(3)/2)*sqrt(gram)/(5*second)
try:

assert convert_to(statcoulomb, coulomb, cgs_gauss) == coulomb/2997924580
assert convert_to(coulomb, statcoulomb, cgs_gauss) == 2997924580*statcoulomb
assert convert_to(statcoulomb, sqrt(gram*centimeter**3)/second, cgs_gauss) == centimeter**(S(3)/2)*sqrt(gram)/second
assert convert_to(coulomb, sqrt(gram*centimeter**3)/second, cgs_gauss) == 149896229*centimeter**(S(3)/2)*sqrt(gram)/(5*second)

# SI units have an additional base unit, no conversion in case of electromagnetism:
assert convert_to(coulomb, statcoulomb, SI) == coulomb
assert convert_to(statcoulomb, coulomb, SI) == statcoulomb
assert convert_to(coulomb, statcoulomb, SI) == coulomb
assert convert_to(statcoulomb, coulomb, SI) == statcoulomb

# SI without electromagnetism:
assert convert_to(erg, joule, SI) == joule/10**7
assert convert_to(erg, joule, cgs_gauss) == joule/10**7
assert convert_to(joule, erg, SI) == 10**7*erg
assert convert_to(joule, erg, cgs_gauss) == 10**7*erg

assert convert_to(dyne, newton, SI) == newton/10**5
assert convert_to(dyne, newton, cgs_gauss) == newton/10**5
assert convert_to(newton, dyne, SI) == 10**5*dyne
assert convert_to(newton, dyne, cgs_gauss) == 10**5*dyne
assert convert_to(erg, joule, SI) == joule/10**7
assert convert_to(erg, joule, cgs_gauss) == joule/10**7
assert convert_to(joule, erg, SI) == 10**7*erg
assert convert_to(joule, erg, cgs_gauss) == 10**7*erg

assert convert_to(dyne, newton, SI) == newton/10**5
assert convert_to(dyne, newton, cgs_gauss) == newton/10**5
assert convert_to(newton, dyne, SI) == 10**5*dyne
assert convert_to(newton, dyne, cgs_gauss) == 10**5*dyne
except AssertionError as msg:
return msg


def test_cgs_gauss_convert_constants():
Expand Down