Installation¶
Import NumpSy
[2]:
import numpsy as nsy
Units¶
Declare a Unit¶
[6]:
meter = nsy.Unit(name="meter", symbol="m")
meter
[6]:
Unit |
|
---|---|
name |
meter |
symbol |
\begin{equation}m\end{equation} |
symbolic_expression |
\begin{equation}Ø\end{equation} |
Retrieve attributes from this Unit¶
[3]:
meter.s
[3]:
[4]:
meter.symbol
[4]:
[5]:
meter.name
[5]:
'meter'
Operate with this unit¶
[6]:
farad_per_meter = nsy.Unit(name="Farad", symbol="F") / meter
farad_per_meter
[6]:
Unit |
|
---|---|
name |
(Farad)per(meter) |
symbol |
\begin{equation}Ø\end{equation} |
symbolic_expression |
\begin{equation}\frac{F}{m}\end{equation} |
Append to Unit Library¶
[7]:
nsy.Units().data
[7]:
Hertz Unit name name_expression ...
Farad Unit name name_expression ...
meter Unit name name_expression ...
ohm Unit name name_expression ...
ratio Unit name name_expression ...
second Unit name name_expression ...
Name: 0, dtype: object
[8]:
nsy.u
[8]:
Hertz Unit name name_expression ...
Farad Unit name name_expression ...
meter Unit name name_expression ...
ohm Unit name name_expression ...
ratio Unit name name_expression ...
second Unit name name_expression ...
Name: 0, dtype: object
Constant¶
[9]:
e_0 = nsy.Constant(
name="permittivity_vaccum",
symbol= "\epsilon_0",
numerical=8.8541878128e-12,
unit=farad_per_meter
)
e_0
[9]:
Constant |
|
---|---|
name |
permittivity_vaccum |
symbol |
\begin{equation}\epsilon_0\end{equation} |
symbolic_expression |
\begin{equation}Ø\end{equation} |
numerical |
8.8541878128e-12 |
unit |
Symbol: \begin{equation}Ø\end{equation} |
Symbolic Expression: \begin{equation}\frac{F}{m}\end{equation} |
[10]:
e_0.s
[10]:
[11]:
e_0.n
[11]:
8.8541878128e-12
[12]:
e_d = nsy.Constant(
name="dielectric_permittivity",
symbol= "\epsilon_d",
numerical=5,
unit=nsy.u.ratio
)
e_d
[12]:
Constant |
|
---|---|
name |
dielectric_permittivity |
symbol |
\begin{equation}\epsilon_d\end{equation} |
symbolic_expression |
\begin{equation}Ø\end{equation} |
numerical |
5 |
unit |
Symbol: \begin{equation}\end{equation} |
Symbolic Expression: \begin{equation}Ø\end{equation} |
Constants cannot be mutated¶
[13]:
e_d.n = 10
Constant cannot be mutated. You cannot set any attribute value. Instantiate a new variable.
Variable¶
[14]:
capacitor_plate_separation = nsy.Variable(
name="capacitor_plate_separation",
symbol= "d",
numerical=None,
unit=nsy.u.meter
)
capacitor_plate_separation
[14]:
Variable |
|
---|---|
name |
capacitor_plate_separation |
symbol |
\begin{equation}d\end{equation} |
symbolic_expression |
\begin{equation}Ø\end{equation} |
numerical |
|
unit |
Symbol: \begin{equation}m\end{equation} |
Symbolic Expression: \begin{equation}Ø\end{equation} |
[15]:
capacitor_plate_separation.s
[15]:
[16]:
capacitor_plate_separation.u
[16]:
Unit |
|
---|---|
name |
meter |
symbol |
\begin{equation}m\end{equation} |
symbolic_expression |
\begin{equation}Ø\end{equation} |
Variables can be mutated¶
[17]:
capacitor_plate_separation.n = 1e-6
capacitor_plate_separation.n
[17]:
1e-06
[18]:
capacitor_plate_separation.numerical = 3e-5
capacitor_plate_separation.numerical
[18]:
3e-05
Operate between Value objects¶
Constants and Variables are value objects.
[19]:
capacitance_per_plate_cross_sectional_area = e_d / (e_0 * capacitor_plate_separation)
capacitance_per_plate_cross_sectional_area
[19]:
Value |
|
---|---|
name |
|
symbol |
\begin{equation}Ø\end{equation} |
symbolic_expression |
\begin{equation}\frac{\epsilon_d}{\epsilon_0 d}\end{equation} |
numerical |
1.8823484456216984e+16 |
unit |
Symbol: \begin{equation}Ø\end{equation} |
Symbolic Expression: \begin{equation}\frac{}{F}\end{equation} |
[20]:
capacitance_per_plate_cross_sectional_area.se
[20]:
[21]:
capacitance_per_plate_cross_sectional_area.n
[21]:
1.8823484456216984e+16
Perform Flexible Class Operations¶
[22]:
raw_capacitor_cross_sectional_area = (1e-6) ** 2
raw_capacitor_cross_sectional_area
[22]:
1e-12
[23]:
device_capacitance = capacitance_per_plate_cross_sectional_area * raw_capacitor_cross_sectional_area
device_capacitance
[23]:
Value |
|
---|---|
name |
|
symbol |
\begin{equation}Ø\end{equation} |
symbolic_expression |
\begin{equation}\frac{\epsilon_d Ø}{\epsilon_0 d}\end{equation} |
numerical |
18823.484456216982 |
unit |
Symbol: \begin{equation}Ø\end{equation} |
Symbolic Expression: \begin{equation}\frac{Ø}{F}\end{equation} |
[24]:
device_capacitance.name
[24]:
''
[25]:
device_capacitance.se
[25]:
[26]:
device_capacitance.symbol = "F"
device_capacitance.symbol
[26]:
[27]:
raw_capacitor_cross_sectional_area
[27]:
1e-12
Example Functions¶
[28]:
nsy.sqrt(device_capacitance)
[28]:
Value |
|
---|---|
name |
|
symbol |
\begin{equation}Ø\end{equation} |
symbolic_expression |
\begin{equation}\sqrt{F}\end{equation} |
numerical |
137.19870428038664 |
unit |
Symbol: \begin{equation}Ø\end{equation} |
Symbolic Expression: \begin{equation}\sqrt{\frac{Ø}{F}}\end{equation} |
[29]:
nsy.sinh(device_capacitance)
/Users/daquintero/Documents/numpsy/numpsy/functions.py:53: RuntimeWarning: overflow encountered in sinh
new.numerical = np.sinh(instance_parameters["numerical"])
[29]:
Value |
|
---|---|
name |
|
symbol |
\begin{equation}Ø\end{equation} |
symbolic_expression |
\begin{equation}\sinh{\left(F \right)}\end{equation} |
numerical |
inf |
unit |
Symbol: \begin{equation}Ø\end{equation} |
Symbolic Expression: \begin{equation}\sqrt{\frac{Ø}{F}}\end{equation} |