From 2da72cdb60b8f27ac2ca4975ad6a72fc292d73fe Mon Sep 17 00:00:00 2001
From: Jan Dinkelbach <jdinkelbach@eonerc.rwth-aachen.de>
Date: Fri, 2 Aug 2019 12:31:19 +0200
Subject: [PATCH] minor update on lecture 2 notebooks
---
Index.ipynb | 4 +-
lectures/02_NA_MNA/VS_CS_R4.ipynb | 6 +-
lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb | 105 +++++++++++++------
3 files changed, 80 insertions(+), 35 deletions(-)
diff --git a/Index.ipynb b/Index.ipynb
index 61e85e3..0fcc874 100644
--- a/Index.ipynb
+++ b/Index.ipynb
@@ -11,8 +11,8 @@
"The following notebooks are currently available: \n",
"\n",
"Lecture Examples:\n",
- "- [Lecture 2 - Modified Nodal Analysis - with DPsim solver](./lectures/02_NA_MNA/VS_CS_R4.ipynb)\n",
- "- [Lecture 2 - Modified Nodal Analysis - without DPsim solver](./lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb)\n",
+ "- [Lecture 2 - Modified Nodal Analysis - without DPsim](./lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb)\n",
+ "- [Lecture 2 - Modified Nodal Analysis - with DPsim](./lectures/02_NA_MNA/VS_CS_R4.ipynb)\n",
"- [Lecture 3 - Resistive Companion](./lectures/03_ResistiveCompanion/VS_R2L3.ipynb)\n",
"- [Lecture 4 - Nonlinear Resistive Companion](./lectures/04_NLResistiveCompanion/NL_RC.ipynb)\n",
"- [Lecture 5 - State Space Equations](./lectures/05_StateSpace/StateEq_ASMG.ipynb)\n",
diff --git a/lectures/02_NA_MNA/VS_CS_R4.ipynb b/lectures/02_NA_MNA/VS_CS_R4.ipynb
index 702bc0b..c0e752b 100644
--- a/lectures/02_NA_MNA/VS_CS_R4.ipynb
+++ b/lectures/02_NA_MNA/VS_CS_R4.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# MSP Simulation Example - Modified Nodal Analysis"
+ "# MSP Simulation Example - Modified Nodal Analysis - with DPsim"
]
},
{
@@ -383,9 +383,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.0"
+ "version": "3.7.3"
}
},
"nbformat": 4,
- "nbformat_minor": 2
+ "nbformat_minor": 4
}
diff --git a/lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb b/lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb
index 3e33b00..00f1c47 100644
--- a/lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb
+++ b/lectures/02_NA_MNA/VS_CS_R4_hard-coded.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# MSP Simulation Example - Modified Nodal Analysis - without the DPsim solver"
+ "# MSP Simulation Example - Modified Nodal Analysis - without DPsim"
]
},
{
@@ -26,7 +26,7 @@
"metadata": {},
"source": [
"$R_1$: $1 \\Omega$, $R_2$: $1 \\Omega$, $R_3$: $10 \\Omega$, $R_4$: $5 \\Omega$ \n",
- "$I_1$: $1 A$, $V_{in}$: $10 V$"
+ "$I_1$: $1 A$, $V_{0}$: $10 V$"
]
},
{
@@ -38,7 +38,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -50,17 +50,20 @@
"R2= 1.0\n",
"R3= 10.0\n",
"R4= 5.0\n",
- "I_src= 1.0\n",
- "V_src= 10.0\n"
+ "I_1= 1.0\n",
+ "V_0= 10.0\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "Derive the admittance matrix G and the source vector A applied in nodal analysis using the matrix stamp approach. Note here that there are two approaches to stamp the voltage source:\n",
- "1. **NA**: Stamp the voltage source as **real** voltage source with internal resistance R1 and transform it into a current source using Norton transformation --> 2 nodes + 1 reference node\n",
- "2. **MNA**: Stamp the voltage source as **ideal** voltage source. --> 3 nodes + 1 reference node"
+ "Derive the admittance matrix G and the source vector A applied in nodal analysis using the matrix stamp approach. Note here, that there are in general two approaches to stamp a voltage source connected in series with a resistor:\n",
+ "\n",
+ "1. **NA**: Stamp the voltage source as **real** voltage source with the resistor as internal resistance (here R1) and transform it into a current source using Norton transformation (2 nodes involved).\n",
+ "2. **MNA**: Stamp the voltage source as **ideal** voltage source (3 nodes involved)\n",
+ "\n",
+ "In the following, we apply the second option. "
]
},
{
@@ -72,7 +75,36 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "#Building source vector\n",
+ "A_src = np.array([[0] ,\n",
+ " [0] ,\n",
+ " [I_1] ,\n",
+ " [V_0]])\n",
+ "\n",
+ "#Building admitance matrix\n",
+ "G = np.array([[1/R1, -1/R1 , 0 , 1],\n",
+ " [-1/R1, (1/R1 + 1/R2 + 1/R3) , -1/R3 , 0],\n",
+ " [0 , -1/R3, (1/R3 + 1/R4), 0],\n",
+ " [1, 0, 0, 0]])\n",
+ " \n",
+ "#System solution\n",
+ "e_nodes = np.matmul(np.linalg.inv(G),A_src)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Problem formulation"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -85,8 +117,38 @@
" [ 0. -0.1 0.3 0. ]\n",
" [ 1. 0. 0. 0. ]]\n",
"\n",
- "Problem size: 4x4\n",
+ "Source vector: \n",
+ "[[ 0.]\n",
+ " [ 0.]\n",
+ " [ 1.]\n",
+ " [ 10.]]\n",
"\n",
+ "Size: 4x4\n"
+ ]
+ }
+ ],
+ "source": [
+ "print('Admitance matrix: \\n' + str(G))\n",
+ "print('\\nSource vector: \\n' + str(A_src))\n",
+ "print('\\nSize: 4x4')"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Problem solution"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
"Node Voltages: \n",
"[[ 10.]\n",
" [ 5.]\n",
@@ -98,24 +160,7 @@
}
],
"source": [
- "#Building source vector\n",
- "A_src = np.array([[0] ,\n",
- " [0] ,\n",
- " [I_src] ,\n",
- " [V_src]])\n",
- "\n",
- "#Building admitance matrix\n",
- "G = np.array([[1/R1, -1/R1 , 0 , 1],\n",
- " [-1/R1, (1/R1 + 1/R2 + 1/R3) , -1/R3 , 0],\n",
- " [0 , -1/R3, (1/R3 + 1/R4), 0],\n",
- " [1, 0, 0, 0]])\n",
- " \n",
- "#System solution\n",
- "e_nodes = np.matmul(np.linalg.inv(G),A_src)\n",
- "\n",
- "print('Admitance matrix: \\n' + str(G))\n",
- "print('\\nProblem size: 4x4')\n",
- "print('\\nNode Voltages: \\n' + str(e_nodes[0:3 , :]))\n",
+ "print('Node Voltages: \\n' + str(e_nodes[0:3 , :]))\n",
"print('\\nCurrent i_10 through the voltage source: \\n'+ str(-e_nodes[1 , :]))"
]
},
@@ -130,7 +175,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -165,7 +210,7 @@
"\n",
"print('Admitance matrix: \\n' + str(G))\n",
"print('\\nLower triangular matrix: \\n' + str(L))\n",
- "print('\\nUpper triangular matrix: \\n'+ str(U))\n"
+ "print('\\nUpper triangular matrix: \\n'+ str(U))"
]
},
{
--
GitLab