| 1 | {
|
|---|
| 2 | "cells": [
|
|---|
| 3 | {
|
|---|
| 4 | "cell_type": "code",
|
|---|
| 5 | "execution_count": 1,
|
|---|
| 6 | "metadata": {},
|
|---|
| 7 | "outputs": [
|
|---|
| 8 | {
|
|---|
| 9 | "name": "stderr",
|
|---|
| 10 | "output_type": "stream",
|
|---|
| 11 | "text": [
|
|---|
| 12 | "2021-02-08 14:43:06,701 - OMPython - INFO - OMC Server is up and running at file:///C:/Users/J5046~1.ALV/AppData/Local/Temp/openmodelica.port.b925b3c77883403b95e5226c65cc6cfe pid=13232\n"
|
|---|
| 13 | ]
|
|---|
| 14 | },
|
|---|
| 15 | {
|
|---|
| 16 | "name": "stdout",
|
|---|
| 17 | "output_type": "stream",
|
|---|
| 18 | "text": [
|
|---|
| 19 | "Notification: Automatically loaded package Modelica 3.2.3 due to uses annotation.\n",
|
|---|
| 20 | "Notification: Automatically loaded package Complex 3.2.3 due to uses annotation.\n",
|
|---|
| 21 | "Notification: Automatically loaded package ModelicaServices 3.2.3 due to uses annotation.\n",
|
|---|
| 22 | "Notification: Skipped loading package OpenIPSL (1.5.0) using MODELICAPATH C:/Users/j.alves/Desktop/;C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).\n",
|
|---|
| 23 | "Notification: Skipped loading package Dynawo (0.1) using MODELICAPATH C:/Users/j.alves/Desktop/;C:/OpenModelica/lib/omlibrary (uses-annotation may be wrong).\n",
|
|---|
| 24 | "\n",
|
|---|
| 25 | "Warning: Requested package Modelica of version 3.2.2, but this package was already loaded with version 3.2.3. You might experience problems if these versions are incompatible.\n",
|
|---|
| 26 | "Warning: Requested package Complex of version 3.2.2, but this package was already loaded with version 3.2.3. You might experience problems if these versions are incompatible.\n",
|
|---|
| 27 | "\n",
|
|---|
| 28 | "Expected end of text, found '-' (at char 6929), (line:58, col:192)\n",
|
|---|
| 29 | "Expected end of text, found '-' (at char 6929), (line:58, col:192)\n"
|
|---|
| 30 | ]
|
|---|
| 31 | }
|
|---|
| 32 | ],
|
|---|
| 33 | "source": [
|
|---|
| 34 | "from OMPython import ModelicaSystem\n",
|
|---|
| 35 | "mod = ModelicaSystem(\"C:/Users/j.alves/Desktop/HVDCcomponents/package.mo\",\"HVDCcomponents.Examples.Test_VSC\",[\"C:/Users/j.alves/Desktop/OpenIPSL/package.mo\"])\n",
|
|---|
| 36 | "mod.buildModel()"
|
|---|
| 37 | ]
|
|---|
| 38 | },
|
|---|
| 39 | {
|
|---|
| 40 | "cell_type": "code",
|
|---|
| 41 | "execution_count": 2,
|
|---|
| 42 | "metadata": {},
|
|---|
| 43 | "outputs": [
|
|---|
| 44 | {
|
|---|
| 45 | "data": {
|
|---|
| 46 | "text/plain": [
|
|---|
| 47 | "('OpenIPSL', 'ModelicaServices', 'Complex', 'Modelica', 'HVDCcomponents')"
|
|---|
| 48 | ]
|
|---|
| 49 | },
|
|---|
| 50 | "execution_count": 2,
|
|---|
| 51 | "metadata": {},
|
|---|
| 52 | "output_type": "execute_result"
|
|---|
| 53 | }
|
|---|
| 54 | ],
|
|---|
| 55 | "source": [
|
|---|
| 56 | "mod.sendExpression(\"getClassNames()\")"
|
|---|
| 57 | ]
|
|---|
| 58 | },
|
|---|
| 59 | {
|
|---|
| 60 | "cell_type": "code",
|
|---|
| 61 | "execution_count": 3,
|
|---|
| 62 | "metadata": {},
|
|---|
| 63 | "outputs": [
|
|---|
| 64 | {
|
|---|
| 65 | "name": "stdout",
|
|---|
| 66 | "output_type": "stream",
|
|---|
| 67 | "text": [
|
|---|
| 68 | "()\n"
|
|---|
| 69 | ]
|
|---|
| 70 | }
|
|---|
| 71 | ],
|
|---|
| 72 | "source": [
|
|---|
| 73 | "OutputFile = 'output'\n",
|
|---|
| 74 | "tim = 1\n",
|
|---|
| 75 | "t0 = \"0\"\n",
|
|---|
| 76 | "tf = \"20\"\n",
|
|---|
| 77 | "step = \"0.00002\"\n",
|
|---|
| 78 | "tol = \"1e-06\"\n",
|
|---|
| 79 | "method = \"dassl\"\n",
|
|---|
| 80 | "simOptions = [\n",
|
|---|
| 81 | " \"startTime\" + \"=\" + t0,\n",
|
|---|
| 82 | " \"stopTime\" + \"=\" + tf,\n",
|
|---|
| 83 | " \"stepSize\" + \"=\" + step,\n",
|
|---|
| 84 | " \"tolerance\" + \"=\" + tol,\n",
|
|---|
| 85 | " \"solver\" + \"=\" + method\n",
|
|---|
| 86 | " ]\n",
|
|---|
| 87 | "\n",
|
|---|
| 88 | "mod.setSimulationOptions(simOptions)\n",
|
|---|
| 89 | "# Simulate the model \n",
|
|---|
| 90 | "mod.simulate(resultfile= OutputFile + \".mat\") \n",
|
|---|
| 91 | "\n",
|
|---|
| 92 | "\n",
|
|---|
| 93 | "var = mod.getSolutions()\n",
|
|---|
| 94 | "print(var)"
|
|---|
| 95 | ]
|
|---|
| 96 | },
|
|---|
| 97 | {
|
|---|
| 98 | "cell_type": "code",
|
|---|
| 99 | "execution_count": 7,
|
|---|
| 100 | "metadata": {},
|
|---|
| 101 | "outputs": [
|
|---|
| 102 | {
|
|---|
| 103 | "ename": "ParseException",
|
|---|
| 104 | "evalue": "Expected end of text, found '(' (at char 4), (line:1, col:5)",
|
|---|
| 105 | "output_type": "error",
|
|---|
| 106 | "traceback": [
|
|---|
| 107 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
|---|
| 108 | "\u001b[1;31mParseException\u001b[0m Traceback (most recent call last)",
|
|---|
| 109 | "\u001b[1;32m<ipython-input-7-9fc2de226609>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mmod\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetSolutions\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"pQ_sensor1.P12\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
|
|---|
| 110 | "\u001b[1;32mc:\\python38\\lib\\site-packages\\OMPython\\__init__.py\u001b[0m in \u001b[0;36mgetSolutions\u001b[1;34m(self, varList, resultfile)\u001b[0m\n\u001b[0;32m 1158\u001b[0m \u001b[0mvariables\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\",\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mvarList\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1159\u001b[0m \u001b[0mexp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"readSimulationResult(\\\"\"\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mresFile\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;34m'\",{'\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mvariables\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;34m\"})\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1160\u001b[1;33m \u001b[0mres\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetconn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msendExpression\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexp\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1161\u001b[0m \u001b[0mnpRes\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marray\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mres\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1162\u001b[0m \u001b[0mexp2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"closeSimulationResultFile()\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|---|
| 111 | "\u001b[1;32mc:\\python38\\lib\\site-packages\\OMPython\\__init__.py\u001b[0m in \u001b[0;36msendExpression\u001b[1;34m(self, command, parsed)\u001b[0m\n\u001b[0;32m 629\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_omc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrecv_string\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 630\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mparsed\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 631\u001b[1;33m \u001b[0manswer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mOMTypedParser\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mparseString\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 632\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0manswer\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 633\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|---|
| 112 | "\u001b[1;32mc:\\python38\\lib\\site-packages\\OMPython\\OMTypedParser.py\u001b[0m in \u001b[0;36mparseString\u001b[1;34m(string)\u001b[0m\n\u001b[0;32m 118\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 119\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mparseString\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstring\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 120\u001b[1;33m \u001b[0mres\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0momcGrammar\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mparseString\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstring\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 121\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mres\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 122\u001b[0m \u001b[1;32mreturn\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|---|
| 113 | "\u001b[1;32mc:\\python38\\lib\\site-packages\\pyparsing.py\u001b[0m in \u001b[0;36mparseString\u001b[1;34m(self, instring, parseAll)\u001b[0m\n\u001b[0;32m 1953\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'__traceback__'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1954\u001b[0m \u001b[0mexc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__traceback__\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_trim_traceback\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__traceback__\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1955\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mexc\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1956\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1957\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mtokens\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|---|
| 114 | "\u001b[1;32mc:\\python38\\lib\\site-packages\\pyparsing.py\u001b[0m in \u001b[0;36mparseImpl\u001b[1;34m(self, instring, loc, doActions)\u001b[0m\n\u001b[0;32m 3812\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mparseImpl\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minstring\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mloc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdoActions\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3813\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mloc\u001b[0m \u001b[1;33m<\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minstring\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3814\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mParseException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minstring\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mloc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merrmsg\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3815\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mloc\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minstring\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3816\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mloc\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
|
|---|
| 115 | "\u001b[1;31mParseException\u001b[0m: Expected end of text, found '(' (at char 4), (line:1, col:5)"
|
|---|
| 116 | ]
|
|---|
| 117 | }
|
|---|
| 118 | ],
|
|---|
| 119 | "source": [
|
|---|
| 120 | "mod.getSolutions([\"pQ_sensor1.P12\"])"
|
|---|
| 121 | ]
|
|---|
| 122 | },
|
|---|
| 123 | {
|
|---|
| 124 | "cell_type": "code",
|
|---|
| 125 | "execution_count": 5,
|
|---|
| 126 | "metadata": {},
|
|---|
| 127 | "outputs": [
|
|---|
| 128 | {
|
|---|
| 129 | "data": {
|
|---|
| 130 | "text/plain": [
|
|---|
| 131 | "['P_mode', 'PI+filter']"
|
|---|
| 132 | ]
|
|---|
| 133 | },
|
|---|
| 134 | "execution_count": 5,
|
|---|
| 135 | "metadata": {},
|
|---|
| 136 | "output_type": "execute_result"
|
|---|
| 137 | }
|
|---|
| 138 | ],
|
|---|
| 139 | "source": [
|
|---|
| 140 | "mod.getParameters(['vSC_station_final.Vdc_Control_Type','vSC_station_final1.Vdc_Control_Type'])"
|
|---|
| 141 | ]
|
|---|
| 142 | },
|
|---|
| 143 | {
|
|---|
| 144 | "cell_type": "code",
|
|---|
| 145 | "execution_count": 6,
|
|---|
| 146 | "metadata": {},
|
|---|
| 147 | "outputs": [
|
|---|
| 148 | {
|
|---|
| 149 | "data": {
|
|---|
| 150 | "text/plain": [
|
|---|
| 151 | "['P_mode', 'P_mode']"
|
|---|
| 152 | ]
|
|---|
| 153 | },
|
|---|
| 154 | "execution_count": 6,
|
|---|
| 155 | "metadata": {},
|
|---|
| 156 | "output_type": "execute_result"
|
|---|
| 157 | }
|
|---|
| 158 | ],
|
|---|
| 159 | "source": [
|
|---|
| 160 | "mod.setParameters(['vSC_station_final.Vdc_Control_Type = P_mode','vSC_station_final1.Vdc_Control_Type = P_mode'])\n",
|
|---|
| 161 | "mod.getParameters(['vSC_station_final.Vdc_Control_Type','vSC_station_final1.Vdc_Control_Type'])"
|
|---|
| 162 | ]
|
|---|
| 163 | },
|
|---|
| 164 | {
|
|---|
| 165 | "cell_type": "code",
|
|---|
| 166 | "execution_count": null,
|
|---|
| 167 | "metadata": {},
|
|---|
| 168 | "outputs": [],
|
|---|
| 169 | "source": [
|
|---|
| 170 | "mod.simulate(resultfile= OutputFile + \".mat\") \n"
|
|---|
| 171 | ]
|
|---|
| 172 | }
|
|---|
| 173 | ],
|
|---|
| 174 | "metadata": {
|
|---|
| 175 | "kernelspec": {
|
|---|
| 176 | "display_name": "Python 3",
|
|---|
| 177 | "language": "python",
|
|---|
| 178 | "name": "python3"
|
|---|
| 179 | },
|
|---|
| 180 | "language_info": {
|
|---|
| 181 | "codemirror_mode": {
|
|---|
| 182 | "name": "ipython",
|
|---|
| 183 | "version": 3
|
|---|
| 184 | },
|
|---|
| 185 | "file_extension": ".py",
|
|---|
| 186 | "mimetype": "text/x-python",
|
|---|
| 187 | "name": "python",
|
|---|
| 188 | "nbconvert_exporter": "python",
|
|---|
| 189 | "pygments_lexer": "ipython3",
|
|---|
| 190 | "version": "3.8.5"
|
|---|
| 191 | }
|
|---|
| 192 | },
|
|---|
| 193 | "nbformat": 4,
|
|---|
| 194 | "nbformat_minor": 4
|
|---|
| 195 | }
|
|---|