Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified CIE_files/CIE_15_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 68 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,21 @@ sol = system.solve(knowns, guesses,tol=1e-3, verbose=True,careful_steps=30)
print(sol)
```

Undetermined symbols: {x_H+, y, x_He++, n_Htot, x_He+, T, C_2}
y not specified; assuming y=0.09254634923706946.
Undetermined symbols: {C_2, y, T, x_He++, n_Htot, x_H+, x_He+}
C_2 not specified; assuming C_2=1.0.
Free symbols: {x_H+, y, x_He++, n_Htot, T, x_He+, C_2}
y not specified; assuming y=0.09254634923706946.
Free symbols: {x_He+, y, T, x_He++, n_Htot, x_H+, C_2}
Known values: ['T', 'n_Htot']
Assumed values: ['y', 'C_2']
Assumed values: ['C_2', 'y']
Equations solved: ['He+', 'He++', 'H+']
It's solvin time. Solving for {'He++', 'He+', 'H+'} based on input {'T', 'n_Htot'} and assumptions about {'y', 'C_2'}
num_iter average=35.84362030029297 min=18 max=68
{'H+': Array([4.2205894e-16, 4.2205857e-16, 4.2205873e-16, ..., 9.9999940e-01,
9.9999940e-01, 9.9999940e-01], dtype=float32), 'He++': Array([4.2757958e-19, 4.2757628e-19, 4.2757958e-19, ..., 9.2538655e-02,
9.2538655e-02, 9.2538655e-02], dtype=float32), 'He+': Array([8.2595321e-17, 8.2595777e-17, 8.2595466e-17, ..., 7.6925389e-06,
7.6924471e-06, 7.6923561e-06], dtype=float32), 'He': Array([9.254635e-02, 9.254635e-02, 9.254635e-02, ..., 7.450581e-09,
7.450581e-09, 7.450581e-09], dtype=float32), 'H': Array([1.0000000e+00, 1.0000000e+00, 1.0000000e+00, ..., 5.9604645e-07,
5.9604645e-07, 5.9604645e-07], dtype=float32), 'e-': Array([5.0550942e-16, 5.0550947e-16, 5.0550937e-16, ..., 1.1850843e+00,
It's solvin time. Solving for {'He+', 'H+', 'He++'} based on input {'n_Htot', 'T'} and assumptions about {'y', 'C_2'}
num_iter average=35.819149017333984 min=18 max=68
{'He+': Array([2.8003510e-16, 2.8003862e-16, 2.8003910e-16, ..., 7.6925389e-06,
7.6924471e-06, 7.6923561e-06], dtype=float32), 'He++': Array([4.1297267e-17, 4.1297541e-17, 4.1297644e-17, ..., 9.2538655e-02,
9.2538655e-02, 9.2538655e-02], dtype=float32), 'H+': Array([2.5647242e-16, 2.5647083e-16, 2.5647025e-16, ..., 9.9999940e-01,
9.9999940e-01, 9.9999940e-01], dtype=float32), 'H': Array([1.0000000e+00, 1.0000000e+00, 1.0000000e+00, ..., 5.9604645e-07,
5.9604645e-07, 5.9604645e-07], dtype=float32), 'He': Array([9.254635e-02, 9.254635e-02, 9.254635e-02, ..., 7.450581e-09,
7.450581e-09, 7.450581e-09], dtype=float32), 'e-': Array([6.1910205e-16, 6.1910453e-16, 6.1910464e-16, ..., 1.1850843e+00,
1.1850843e+00, 1.1850843e+00], dtype=float32)}


Expand Down Expand Up @@ -187,37 +187,72 @@ Suppose you just want the RHS of the system you're solving, or its Jacobian, bec


```python
print(system.generate_code(('H','He','He+'),language='c'))
print(system.generate_code(('H+','He+','He++'),language='c'))
```

/* Computes the RHS function and Jacobian to solve for [x_He+]
/* Computes the RHS function and Jacobian to solve for [x_He+, x_He++, x_H+]

This code was auto-generated by jaco v0.1.1 and is not intended to be modified or maintained by human beings.

INDEX CONVENTION: (0: x_He+)
INDEX CONVENTION: (0: x_He+) (1: x_He++) (2: x_H+)
*/

x0 = sqrt(T);
x1 = 1.0/x0;
x2 = pow(n_Htot, 2);
x3 = x_Heplus + 2*x_Heplusplus + x_Hplus;
x4 = pow(0.00059608348423850961*x0 + 1.0, -1.748);
x5 = pow(0.2818075618324889*x0 + 1.0, -0.252);
x6 = x2*x_Heplus;
x7 = 1.0/T;
x8 = 1.0/((1.0/1000.0)*sqrt(10)*x0 + 1);
x9 = x0*x8;
x10 = 5.68e-12*x9*exp(-631515*x7);
x11 = x10*x6;
x12 = exp(-285335.40000000002*x7);
x13 = -x_Heplus - x_Heplusplus + y;
x14 = C_2*(0.0019*pow(T, -1.5)*(1 + 0.29999999999999999*exp(-94000.0*x7))*exp(-470000.0*x7) + 1.9324160622805846e-10*x1*pow(0.00016493478118851054*x0 + 1.0, -1.7891999999999999)*pow(4.8416074481177231*x0 + 1.0, -0.21079999999999999));
x15 = x14*x6;
x16 = x2*x3;
x1 = pow(0.2818075618324889*x0 + 1.0, -0.252);
x2 = pow(0.00059608348423850961*x0 + 1.0, -1.748);
x3 = 5.664858634804579e-10*x1*x2;
x4 = pow(n_Htot, 2);
x5 = x_Heplus + 2*x_Heplusplus + x_Hplus;
x6 = x4*x5;
x7 = 1.0/x0;
x8 = C_2*x7;
x9 = x6*x8;
x10 = x3*x9;
x11 = x10*x_Heplusplus;
x12 = x4*x_Heplus;
x13 = 1.0/T;
x14 = exp(-631515*x13);
x15 = 1.0/((1.0/1000.0)*sqrt(10)*x0 + 1);
x16 = x0*x15;
x17 = 5.68e-12*x14*x16;
x18 = x12*x17;
x19 = x18*x5;
x20 = exp(-285335.40000000002*x13);
x21 = -x_Heplus - x_Heplusplus + y;
x22 = C_2*(0.0019*pow(T, -1.5)*(1 + 0.29999999999999999*exp(-94000.0*x13))*exp(-470000.0*x13) + 1.9324160622805846e-10*x7*pow(0.00016493478118851054*x0 + 1.0, -1.7891999999999999)*pow(4.8416074481177231*x0 + 1.0, -0.21079999999999999));
x23 = x12*x22;
x24 = pow(0.56361512366497779*x0 + 1.0, -0.252);
x25 = pow(0.0011921669684770192*x0 + 1.0, -1.748);
x26 = 1.4162146587011448e-10*x24*x25;
x27 = x26*x9;
x28 = 1 - x_Hplus;
x29 = exp(-157809.10000000001*x13);
x30 = x16*x6;
x31 = 2.3800000000000001e-11*x20*x30;
x32 = x4*x8;
x33 = x32*x_Heplusplus;
x34 = x3*x33;
x35 = x18 - x34;
x36 = x17*x6 + x35;
x37 = -2.3800000000000001e-11*x0*x15*x20*x21*x4 + x23;
x38 = 1.1329717269609158e-9*x1*x2*x33;
x39 = 1.136e-11*x12*x14*x16;
x40 = x32*x_Hplus;
x41 = -5.8500000000000005e-11*x0*x15*x28*x29*x4 + x26*x40;

rhs_result[0] = 5.664858634804579e-10*C_2*x1*x2*x3*x4*x5*x_Heplusplus + 2.3800000000000001e-11*x0*x12*x13*x2*x3*x8 - x11*x3 - x15*x3;
rhs_result[0] = 2.3800000000000001e-11*x0*x15*x20*x21*x4*x5 + x11 - x19 - x23*x5;
rhs_result[1] = -x11 + x19;
rhs_result[2] = 5.8500000000000005e-11*x0*x15*x28*x29*x4*x5 - x27*x_Hplus;

jac_result[0] = 5.664858634804579e-10*C_2*x1*x2*x4*x5*x_Heplusplus + 2.3800000000000001e-11*x0*x12*x13*x2*x8 - x10*x16 - x11 - 2.3800000000000001e-11*x12*x16*x9 - x14*x16 - x15;
jac_result[0] = -x22*x6 - x31 - x36 - x37;
jac_result[1] = 4.7600000000000002e-11*x0*x15*x20*x21*x4 + x10 - 2*x23 - x31 + x38 - x39;
jac_result[2] = -x35 - x37;
jac_result[3] = x36;
jac_result[4] = -x10 - x38 + x39;
jac_result[5] = x18 - x34;
jac_result[6] = -x41;
jac_result[7] = 1.1700000000000001e-10*x0*x15*x28*x29*x4 - 2.8324293174022895e-10*x24*x25*x40;
jac_result[8] = -x27 - 5.8500000000000005e-11*x29*x30 - x41;


Let's break down what happened there. First, jaco is generating the symbolic functions needed to solve the system, as it needs to do before it solves the system with its own solver:
Expand Down
Binary file modified docs/source/CIE_15_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 68 additions & 33 deletions docs/source/Quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ The ``solve`` method calls the JAX solver and computes the solution:

.. parsed-literal::

Undetermined symbols: {x_H+, y, x_He++, n_Htot, x_He+, T, C_2}
y not specified; assuming y=0.09254634923706946.
Undetermined symbols: {C_2, y, T, x_He++, n_Htot, x_H+, x_He+}
C_2 not specified; assuming C_2=1.0.
Free symbols: {x_H+, y, x_He++, n_Htot, T, x_He+, C_2}
y not specified; assuming y=0.09254634923706946.
Free symbols: {x_He+, y, T, x_He++, n_Htot, x_H+, C_2}
Known values: ['T', 'n_Htot']
Assumed values: ['y', 'C_2']
Assumed values: ['C_2', 'y']
Equations solved: ['He+', 'He++', 'H+']
It's solvin time. Solving for {'He++', 'He+', 'H+'} based on input {'T', 'n_Htot'} and assumptions about {'y', 'C_2'}
num_iter average=35.84362030029297 min=18 max=68
{'H+': Array([4.2205894e-16, 4.2205857e-16, 4.2205873e-16, ..., 9.9999940e-01,
9.9999940e-01, 9.9999940e-01], dtype=float32), 'He++': Array([4.2757958e-19, 4.2757628e-19, 4.2757958e-19, ..., 9.2538655e-02,
9.2538655e-02, 9.2538655e-02], dtype=float32), 'He+': Array([8.2595321e-17, 8.2595777e-17, 8.2595466e-17, ..., 7.6925389e-06,
7.6924471e-06, 7.6923561e-06], dtype=float32), 'He': Array([9.254635e-02, 9.254635e-02, 9.254635e-02, ..., 7.450581e-09,
7.450581e-09, 7.450581e-09], dtype=float32), 'H': Array([1.0000000e+00, 1.0000000e+00, 1.0000000e+00, ..., 5.9604645e-07,
5.9604645e-07, 5.9604645e-07], dtype=float32), 'e-': Array([5.0550942e-16, 5.0550947e-16, 5.0550937e-16, ..., 1.1850843e+00,
It's solvin time. Solving for {'He+', 'H+', 'He++'} based on input {'n_Htot', 'T'} and assumptions about {'y', 'C_2'}
num_iter average=35.819149017333984 min=18 max=68
{'He+': Array([2.8003510e-16, 2.8003862e-16, 2.8003910e-16, ..., 7.6925389e-06,
7.6924471e-06, 7.6923561e-06], dtype=float32), 'He++': Array([4.1297267e-17, 4.1297541e-17, 4.1297644e-17, ..., 9.2538655e-02,
9.2538655e-02, 9.2538655e-02], dtype=float32), 'H+': Array([2.5647242e-16, 2.5647083e-16, 2.5647025e-16, ..., 9.9999940e-01,
9.9999940e-01, 9.9999940e-01], dtype=float32), 'H': Array([1.0000000e+00, 1.0000000e+00, 1.0000000e+00, ..., 5.9604645e-07,
5.9604645e-07, 5.9604645e-07], dtype=float32), 'He': Array([9.254635e-02, 9.254635e-02, 9.254635e-02, ..., 7.450581e-09,
7.450581e-09, 7.450581e-09], dtype=float32), 'e-': Array([6.1910205e-16, 6.1910453e-16, 6.1910464e-16, ..., 1.1850843e+00,
1.1850843e+00, 1.1850843e+00], dtype=float32)}


Expand Down Expand Up @@ -184,39 +184,74 @@ can do that too with ``generate_code``.

.. code:: ipython3

print(system.generate_code(('H','He','He+'),language='c'))
print(system.generate_code(('H+','He+','He++'),language='c'))


.. parsed-literal::

/* Computes the RHS function and Jacobian to solve for [x_He+]
/* Computes the RHS function and Jacobian to solve for [x_He+, x_He++, x_H+]

This code was auto-generated by jaco v0.1.1 and is not intended to be modified or maintained by human beings.

INDEX CONVENTION: (0: x_He+)
INDEX CONVENTION: (0: x_He+) (1: x_He++) (2: x_H+)
*/

x0 = sqrt(T);
x1 = 1.0/x0;
x2 = pow(n_Htot, 2);
x3 = x_Heplus + 2*x_Heplusplus + x_Hplus;
x4 = pow(0.00059608348423850961*x0 + 1.0, -1.748);
x5 = pow(0.2818075618324889*x0 + 1.0, -0.252);
x6 = x2*x_Heplus;
x7 = 1.0/T;
x8 = 1.0/((1.0/1000.0)*sqrt(10)*x0 + 1);
x9 = x0*x8;
x10 = 5.68e-12*x9*exp(-631515*x7);
x11 = x10*x6;
x12 = exp(-285335.40000000002*x7);
x13 = -x_Heplus - x_Heplusplus + y;
x14 = C_2*(0.0019*pow(T, -1.5)*(1 + 0.29999999999999999*exp(-94000.0*x7))*exp(-470000.0*x7) + 1.9324160622805846e-10*x1*pow(0.00016493478118851054*x0 + 1.0, -1.7891999999999999)*pow(4.8416074481177231*x0 + 1.0, -0.21079999999999999));
x15 = x14*x6;
x16 = x2*x3;
x1 = pow(0.2818075618324889*x0 + 1.0, -0.252);
x2 = pow(0.00059608348423850961*x0 + 1.0, -1.748);
x3 = 5.664858634804579e-10*x1*x2;
x4 = pow(n_Htot, 2);
x5 = x_Heplus + 2*x_Heplusplus + x_Hplus;
x6 = x4*x5;
x7 = 1.0/x0;
x8 = C_2*x7;
x9 = x6*x8;
x10 = x3*x9;
x11 = x10*x_Heplusplus;
x12 = x4*x_Heplus;
x13 = 1.0/T;
x14 = exp(-631515*x13);
x15 = 1.0/((1.0/1000.0)*sqrt(10)*x0 + 1);
x16 = x0*x15;
x17 = 5.68e-12*x14*x16;
x18 = x12*x17;
x19 = x18*x5;
x20 = exp(-285335.40000000002*x13);
x21 = -x_Heplus - x_Heplusplus + y;
x22 = C_2*(0.0019*pow(T, -1.5)*(1 + 0.29999999999999999*exp(-94000.0*x13))*exp(-470000.0*x13) + 1.9324160622805846e-10*x7*pow(0.00016493478118851054*x0 + 1.0, -1.7891999999999999)*pow(4.8416074481177231*x0 + 1.0, -0.21079999999999999));
x23 = x12*x22;
x24 = pow(0.56361512366497779*x0 + 1.0, -0.252);
x25 = pow(0.0011921669684770192*x0 + 1.0, -1.748);
x26 = 1.4162146587011448e-10*x24*x25;
x27 = x26*x9;
x28 = 1 - x_Hplus;
x29 = exp(-157809.10000000001*x13);
x30 = x16*x6;
x31 = 2.3800000000000001e-11*x20*x30;
x32 = x4*x8;
x33 = x32*x_Heplusplus;
x34 = x3*x33;
x35 = x18 - x34;
x36 = x17*x6 + x35;
x37 = -2.3800000000000001e-11*x0*x15*x20*x21*x4 + x23;
x38 = 1.1329717269609158e-9*x1*x2*x33;
x39 = 1.136e-11*x12*x14*x16;
x40 = x32*x_Hplus;
x41 = -5.8500000000000005e-11*x0*x15*x28*x29*x4 + x26*x40;

rhs_result[0] = 5.664858634804579e-10*C_2*x1*x2*x3*x4*x5*x_Heplusplus + 2.3800000000000001e-11*x0*x12*x13*x2*x3*x8 - x11*x3 - x15*x3;
rhs_result[0] = 2.3800000000000001e-11*x0*x15*x20*x21*x4*x5 + x11 - x19 - x23*x5;
rhs_result[1] = -x11 + x19;
rhs_result[2] = 5.8500000000000005e-11*x0*x15*x28*x29*x4*x5 - x27*x_Hplus;

jac_result[0] = 5.664858634804579e-10*C_2*x1*x2*x4*x5*x_Heplusplus + 2.3800000000000001e-11*x0*x12*x13*x2*x8 - x10*x16 - x11 - 2.3800000000000001e-11*x12*x16*x9 - x14*x16 - x15;
jac_result[0] = -x22*x6 - x31 - x36 - x37;
jac_result[1] = 4.7600000000000002e-11*x0*x15*x20*x21*x4 + x10 - 2*x23 - x31 + x38 - x39;
jac_result[2] = -x35 - x37;
jac_result[3] = x36;
jac_result[4] = -x10 - x38 + x39;
jac_result[5] = x18 - x34;
jac_result[6] = -x41;
jac_result[7] = 1.1700000000000001e-10*x0*x15*x28*x29*x4 - 2.8324293174022895e-10*x24*x25*x40;
jac_result[8] = -x27 - 5.8500000000000005e-11*x29*x30 - x41;


Let’s break down what happened there. First, jaco is generating the
Expand Down
103 changes: 69 additions & 34 deletions examples/CIE.ipynb

Large diffs are not rendered by default.