Skip to content

Commit 4f29241

Browse files
committed
added (self.u_abc_k1 = self.u_lim * self.subactions) for calculation of u_abc from subaction state
1 parent abd859c commit 4f29241

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

examples/model_predictive_controllers/pmsm_fcs_mpc_dq_current_control.ipynb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
{
3535
"cell_type": "code",
36-
"execution_count": 11,
36+
"execution_count": 17,
3737
"metadata": {},
3838
"outputs": [],
3939
"source": [
@@ -42,7 +42,7 @@
4242
},
4343
{
4444
"cell_type": "code",
45-
"execution_count": 12,
45+
"execution_count": 18,
4646
"metadata": {},
4747
"outputs": [],
4848
"source": [
@@ -66,7 +66,7 @@
6666
},
6767
{
6868
"cell_type": "code",
69-
"execution_count": 3,
69+
"execution_count": 20,
7070
"metadata": {},
7171
"outputs": [],
7272
"source": [
@@ -94,7 +94,7 @@
9494
},
9595
{
9696
"cell_type": "code",
97-
"execution_count": 13,
97+
"execution_count": 22,
9898
"metadata": {},
9999
"outputs": [],
100100
"source": [
@@ -124,15 +124,19 @@
124124
" self.p = environment.get_wrapper_attr('physical_system').electrical_motor.motor_parameter['p']\n",
125125
" self.abc_to_dq = environment.get_wrapper_attr('physical_system').abc_to_dq_space\n",
126126
" self.prediction_horizon = prediction_horizon # Prediction horizon (typically 1 for FCS-MPC)\n",
127+
"\n",
128+
" # limit values for the normalization\n",
129+
" self.u_lim = environment.get_wrapper_attr('physical_system').limits[env.get_wrapper_attr('state_names').index('u_sd')]\n",
127130
" \n",
128131
" # Get the finite set of voltage vectors from the environment\n",
129132
" self.subactions = -np.power(-1, environment.get_wrapper_attr('physical_system')._converter._subactions)\n",
133+
" self.u_abc_k1 = self.u_lim * self.subactions\n",
130134
" \n",
131135
" def _simulate_sequence(self, i_d, i_q, epsilon_el, omega, ref_i_d, ref_i_q, depth):\n",
132136
" min_cost = float('inf')\n",
133137
" best_sequence = []\n",
134138
"\n",
135-
" for idx, (v_a, v_b, v_c) in enumerate(self.subactions):\n",
139+
" for idx, (v_a, v_b, v_c) in enumerate(self.u_abc_k1):\n",
136140
" # Convert to dq \n",
137141
" v_dq = np.transpose(np.array([self.abc_to_dq(np.array([v_a, v_b, v_c]), epsilon_el + 0.5*omega*self.tau)]))\n",
138142
" v_d, v_q = v_dq[0], v_dq[1]\n",
@@ -199,7 +203,7 @@
199203
},
200204
{
201205
"cell_type": "code",
202-
"execution_count": 14,
206+
"execution_count": 23,
203207
"metadata": {},
204208
"outputs": [],
205209
"source": [
@@ -217,7 +221,7 @@
217221
},
218222
{
219223
"cell_type": "code",
220-
"execution_count": 16,
224+
"execution_count": 24,
221225
"metadata": {},
222226
"outputs": [],
223227
"source": [
@@ -254,13 +258,13 @@
254258
},
255259
{
256260
"cell_type": "code",
257-
"execution_count": 17,
261+
"execution_count": 25,
258262
"metadata": {},
259263
"outputs": [
260264
{
261265
"data": {
262266
"application/vnd.jupyter.widget-view+json": {
263-
"model_id": "47799e64eeb84ba88aaee9f1d299e191",
267+
"model_id": "793190cb48db401cb57950c71587cbe5",
264268
"version_major": 2,
265269
"version_minor": 0
266270
},
@@ -317,14 +321,14 @@
317321
},
318322
{
319323
"cell_type": "code",
320-
"execution_count": 18,
324+
"execution_count": 26,
321325
"metadata": {},
322326
"outputs": [
323327
{
324328
"name": "stdout",
325329
"output_type": "stream",
326330
"text": [
327-
"Reward = -1430.5877421997113\n"
331+
"Reward = -1041.746469033069\n"
328332
]
329333
}
330334
],

0 commit comments

Comments
 (0)