Package: unitcalc
UnitCalcA Python Library for doing Scientific/Engineering mathematics!This library explicity supports the following SI units:Base Units:AmpereCandelaKilogramMeterMolKelvinSecondCompound/Complex Units:NewtonOhmCoulombVoltWattJoulePascalNon Si Units:Pound/lbTonInchFootMileCelciusFahrenheitMinuteHourValues can be created with units not explicitly supported by the above units but they will be represented as combination of the 7 base SI units.Installation:pip install unitcalcUpgrade:pip install unitcalc --upgradeInstalling the development versionclone the develop branch to your computer and execute:pip install <path/to/UnitCalc>Upgrading the development versionpull the latest version from the develop branch then execute the following:pip install <path/to/UnitCalc> --upgradeUsage:1.) Getting Started:>>>fromunitcalcimportPhysics>>>>>># Create a factory object>>>physics=Physics()>>>>>># Create an Ampere Unit>>>A=physics.create(13,"A")>>>A13A>>># Create a Dimensionless Unit>>>no_dim=physics.create(1)>>>no_dim12.) Creating values with custom units>>>fromunitcalcimportPhysics>>>fromunitcalcimportUnits>>>physics=Physics()>>># Unit accepts the 7 base SI units as key-word arguments>>># A-> Ampere>>># K-> Kelvin>>># sec -> second>>># m -> meter>>># kg -> kilogram>>># cd -> candela>>># mol -> Mol>>># Webber kg⋅m2⋅s−2⋅A−1>>>webber=physics.create(1.34,Units(kg=1,m=2,sec=-2,A=-1))>>>webber1.34m²kg/sec²A3.) Creating SI units with different scales>>>fromunitcalcimportPhysics>>>physics=Physics()>>>>>># Create a nanoAmpere>>>nA=physics.create(13,"A",unit_prefix="nano")>>>nA13nA>>># Convert 13nA to Ampere>>># Passing None or "" will return an un-prefixed value>>>A=nA.convert_to_prefix(None)>>>A1.3e-08A4.) Converting between SI and Non-SI units>>>fromunitcalcimportPhysics>>>physics=Physics()>>>>>>C=physics.create(0,"C")>>>F=C.convert_to_unit("F")>>>K=F.convert_to_unit("K")>>>C0⁰C>>>F32.0⁰F>>>K273.15K5.) Maths and conversionsa.) Doubling Temperature>>>fromunitcalcimportPhysics>>>physics=Physics()>>>>>># Double the temperature at 0 oC>>>C=physics.create(0,"C")>>>double_C=C*2>>>C0⁰C>>>double_C273.15⁰Cb.) Addition/Subtraction>>>fromunitcalcimportPhysics>>>physics=Physics()>>>>>>inch=physics.create(12,"In")>>>foot=physics.create(1,"ft")>>>inch+foot24in>>>foot+inch2ft>>>kg=physics.create(1.2,"kg")>>>foot+kgValueError:Cannotperformadditionbecausetheunitsdonotmatch.c.) Powers>>>fromunitcalcimportPhysics>>>physics=Physics()>>>>>>mm=physics.create(1,"meter",unit_prefix="mili")>>>mm**21e-06m²6.) Boolean Operations>>>fromunitcalcimportPhysics>>>physics=Physics()>>>>>>inch=physics.create(12,"In")>>>foot=physics.create(1,"ft")>>>inch==footTrue7.) Constants>>>fromunitcalcimportConstants>>># All Constants>>>ConstantsConstants:Boltzmann:1.380649e-23m²kg/sec²KG:6.6743015e-11m³/sec²kgN0:6.02214076e+23Na:6.02214076e-23/molPlanck:6.62607015e-34m²kg/secR:8.31446261815324m²kg/sec²KmolRydberg_h:10967758.329787835/mRydberg_inf:10973731.557661768/mStefan:5.6703744191844294e-08kg/sec³K⁴Stefan_Boltzmann:5.6703744191844294e-08kg/sec³K⁴Wiens:0.002897771955mKalpha:0.007297352565816523avogadro_constant:6.02214076e-23/molavogadro_number:6.02214076e+23c:299792458m/sece:1.6021766340000001e-19Celectron_rest_mass:9.1093837015e-31kgelementary_charge:1.6021766340000001e-19Cepsilon_0:8.854187816999999e-12sec⁴A²/m³kgfine_structure:0.007297352565816523g:9.80665m/sec²gas_constant:8.31446261815324m²kg/sec²Kmolgravitational_constant:6.6743015e-11m³/sec²kgh:6.62607015e-34m²kg/sechbar:1.0545718176461565e-34m²kg/seck:1.380649e-23m²kg/sec²Km_e:9.1093837015e-31kgm_n:1.67492749804e-27kgm_p:1.67262192369e-27kgmu_0:1.25e-08mkg/sec²A²neutron_rest_mass:1.67492749804e-27kgproton_rest_mass:1.67262192369e-27kgrydberg_h_constant:10967758.329787835/mrydberg_inf_constant:10973731.557661768/msigma:5.6703744191844294e-08kg/sec³K⁴speed_of_light:299792458m/secstandard_gravity:9.80665m/sec²wiens_displacement_constant:0.002897771955mK>>>>>># Speed of light>>>Constants.speed_of_light()299792458m/sec>>>Constants.c()299792458m/sec