From 123a981cc78c7d3c613fac535f94a47f8c3f2119 Mon Sep 17 00:00:00 2001 From: Callum J Hays Date: Wed, 26 Oct 2022 10:49:14 +1000 Subject: [PATCH] docs: update Walkthrough --- examples/Walkthrough.ipynb | 114 +++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/examples/Walkthrough.ipynb b/examples/Walkthrough.ipynb index 9089e82..8aafe09 100644 --- a/examples/Walkthrough.ipynb +++ b/examples/Walkthrough.ipynb @@ -1133,7 +1133,7 @@ "$$ \\frac{m v^{2}}{2} \\hspace{1.25em} \\text{J} $$" ], "text/plain": [ - "" + "" ] }, "execution_count": 23, @@ -1179,7 +1179,7 @@ "$$ A = x y \\hspace{1.25em} \\text{m}^{2} $$" ], "text/plain": [ - "" + "" ] }, "execution_count": 24, @@ -1995,7 +1995,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -2058,11 +2058,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "Evaluating (50 million el np.array inputs) with:\n", - "a = [0.24592131 0.72116644 0.594621 ... 0.11956484 0.27164356 0.15846607] (shape=(50000000,)), and\n", - "b = [1.96485789 1.21226572 1.87852934 ... 1.92052113 1.99205324 1.3492091 ] (shape=(50000000,)):\n", - "Result: [-1.94940741 -0.97442657 -1.78193668 ... -1.91679567 -1.97344519\n", - " -1.33987077] (shape=(50000000,))\n" + "Evaluating (50 million np.array inputs) with:\n", + "a = [0.67638299 0.47513047 0.65707152 ... 0.45795865 0.34331895 0.06702716] (shape=(50000000,)), and\n", + "b = [1.45355829 1.76383047 1.45734502 ... 1.79285022 1.03742292 1.27038427] (shape=(50000000,)):\n", + "Result: [-1.2865993 -1.6986315 -1.30081187 ... -1.7333741 -0.97896804\n", + " -1.26861482] (shape=(50000000,))\n" ] } ], @@ -2091,14 +2091,14 @@ "display(evaluate_a_with_numpy({ a: [1, 2, 3], c: [4, 5, 6] }))\n", "\n", "\n", - "print(f\"Evaluating (50 million el np.array inputs) with:\")\n", + "print(f\"Evaluating (50 million np.array inputs) with:\")\n", "a_arr = np.random.random(50_000_000)\n", "c_arr = np.random.random(50_000_000) + 1\n", "print(f\"a = {a_arr} (shape={c_arr.shape}), and\")\n", "print(f\"b = {c_arr} (shape={c_arr.shape}):\")\n", "res = evaluate_a_with_numpy({ a: a_arr , c: c_arr})\n", "print(f\"Result: {res} (shape={res.shape})\")\n", - "del a_arr, c_arr, res" + "del a_arr, c_arr, res # clean up memory" ] }, { @@ -2112,7 +2112,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -2242,7 +2242,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -2384,7 +2384,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -2553,7 +2553,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "44f06b96eb9e4afea760dc81d2127028", + "model_id": "39aeda38caa94ec4a0e0a5d4cf3087b7", "version_major": 2, "version_minor": 0 }, @@ -2573,7 +2573,7 @@ }, { "data": { - "image/svg+xml": "0246810−505theta(t) radiansDerivative(theta(t), t) radians/secondDerivative(theta(t), (t, 2)) radians/second**2Solution #1t seconds" + "image/svg+xml": "0246810−505theta(t) radiansDerivative(theta(t), t) radians/secondDerivative(theta(t), (t, 2)) radians/second**2Solution #1t seconds" }, "metadata": {}, "output_type": "display_data" @@ -2613,7 +2613,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -2638,16 +2638,30 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If you need a numpy arrays rather than a list of record (common for use with numpy/scipy), use the zip function:" + "If you need a numpy arrays rather than a list of record (common for use with numpy/scipy), use similar conversion code to below:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "times_arr: shape= (6014,) min= 0.0 max= 10.0\n", + "theta_arr: shape= (6014,) min= -1.047213786143383 max= 1.0472125747647159\n" + ] + } + ], "source": [ - "times, (theta, dtheta, ddtheta) = zip(*sim_data)" + "times, data = zip(*sim_data)\n", + "times_arr = np.array(times)\n", + "theta_arr, dtheta_arr, ddtheta_arr = np.array(data).T\n", + "\n", + "print('times_arr:', 'shape=', times_arr.shape, 'min=', times_arr.min(), 'max=', times_arr.max())\n", + "print('theta_arr:', 'shape=', theta_arr.shape, 'min=', theta_arr.min(), 'max=', theta_arr.max())" ] }, { @@ -2676,7 +2690,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 38, "metadata": {}, "outputs": [ { @@ -2721,12 +2735,12 @@ "source": [ "### VectorSpace Arithmetic\n", "\n", - "New vector spaces (retaining their reference frame name) can be constructed via arithmetic with a `Val` using the `\"*/+-\"` operators:" + "New vector spaces (retaining their reference frame name) can be constructed via arithmetic with a `Val` using the `*` and `/` operators:" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -2741,14 +2755,14 @@ "[meter/second]])" ] }, - "execution_count": 33, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "VelWrtO3 = O3 / s\n", - "VelWrtO3\n" + "VelWrtO3" ] }, { @@ -2762,7 +2776,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": {}, "outputs": [ { @@ -2777,7 +2791,7 @@ "[meter/second]])" ] }, - "execution_count": 34, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -2802,7 +2816,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "metadata": {}, "outputs": [ { @@ -2952,7 +2966,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -2971,7 +2985,7 @@ "[a, 2*a, 3*a] wrt. O3" ] }, - "execution_count": 36, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -2997,7 +3011,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": {}, "outputs": [ { @@ -3051,7 +3065,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": {}, "outputs": [ { @@ -3152,7 +3166,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": {}, "outputs": [ { @@ -3253,7 +3267,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": {}, "outputs": [ { @@ -3291,7 +3305,7 @@ "[1, 2, 3] wrt. O3" ] }, - "execution_count": 40, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -3318,7 +3332,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -3334,7 +3348,7 @@ "$$ \\left[\\begin{matrix}1 & 2 & 3\\\\4 & 5 & 6\\\\7 & 8 & 9\\end{matrix}\\right] \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. R}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3353,7 +3367,7 @@ "$$ \\left[\\begin{matrix}1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 1\\end{matrix}\\right] \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. R}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3372,7 +3386,7 @@ "$$ \\mathbf{A} \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. R}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3430,7 +3444,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 48, "metadata": {}, "outputs": [ { @@ -3486,7 +3500,7 @@ "$$ \\mathbf{A} \\mathbf{B} \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. C}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3505,7 +3519,7 @@ "$$ 2 \\mathbf{A} \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. R}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3517,7 +3531,7 @@ "$$ 0 \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. R}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3536,7 +3550,7 @@ "$$ m \\mathbf{A} \\hspace{1.25em} \\begin{matrix} \\hat{i} \\cdot \\text{m} \\\\ \\hat{j} \\cdot \\text{m} \\\\ \\hat{k} \\cdot \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. L}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{i} \\cdot \\text{kg} \\text{m} \\\\ \\hat{j} \\cdot \\text{kg} \\text{m} \\\\ \\hat{k} \\cdot \\text{kg} \\text{m} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. R}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3620,7 +3634,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -3653,7 +3667,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": {}, "outputs": [ { @@ -3671,7 +3685,7 @@ "$$ \\left[\\begin{matrix}- \\frac{R}{L} & - \\frac{1}{L}\\\\\\frac{1}{c} & 0\\end{matrix}\\right] \\hspace{1.25em} \\begin{matrix} \\hat{v_C} \\cdot \\frac{\\text{V}}{\\text{s}} \\\\ \\hat{i_L} \\cdot \\frac{\\text{A}}{\\text{s}} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCState}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{v_C} \\cdot \\text{V} \\\\ \\hat{i_L} \\cdot \\text{A} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCState}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3692,7 +3706,7 @@ "$$ \\left[\\begin{matrix}\\frac{1}{L}\\\\0\\end{matrix}\\right] \\hspace{1.25em} \\begin{matrix} \\hat{v_C} \\cdot \\frac{\\text{V}}{\\text{s}} \\\\ \\hat{i_L} \\cdot \\frac{\\text{A}}{\\text{s}} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCState}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{v_i} \\cdot \\text{V} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCInput}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3713,7 +3727,7 @@ "$$ \\left[\\begin{matrix}1 & 0\\end{matrix}\\right] \\hspace{1.25em} \\begin{matrix} \\hat{v_o} \\cdot \\text{V} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCOutput}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{v_C} \\cdot \\text{V} \\\\ \\hat{i_L} \\cdot \\text{A} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCState}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -3734,7 +3748,7 @@ "$$ \\left[\\begin{matrix}0\\end{matrix}\\right] \\hspace{1.25em} \\begin{matrix} \\hat{v_o} \\cdot \\text{V} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCOutput}\\normalsize \\hspace{0.75em} ⟷ \\hspace{0.75em} \\begin{matrix} \\hat{v_i} \\cdot \\text{V} \\end{matrix}\\normalsize \\hspace{0.7em} \\small\\text{wrt. RLCInput}\\normalsize $$" ], "text/plain": [ - "" + "" ] }, "metadata": {},