Skip to content

Commit 1bb0a46

Browse files
authored
Merge pull request #990 from murrayrm/fix_ic_update_params-07Apr2024
Fix typo in ICSystem updfcn, outfcn: update_params -> _update_params
2 parents 49f03e7 + 6b00fd4 commit 1bb0a46

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

control/nlsys.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,10 @@ def __init__(self, syslist, connections=None, inplist=None, outlist=None,
706706

707707
# Create updfcn and outfcn
708708
def updfcn(t, x, u, params):
709-
self.update_params(params)
709+
self._update_params(params)
710710
return self._rhs(t, x, u)
711711
def outfcn(t, x, u, params):
712-
self.update_params(params)
712+
self._update_params(params)
713713
return self._out(t, x, u)
714714

715715
# Initialize NonlinearIOSystem object

control/tests/interconnect_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import numpy as np
1818
import scipy as sp
19+
import math
1920

2021
import control as ct
2122

@@ -659,3 +660,32 @@ def test_interconnect_rewrite():
659660
outputs=['y', 'z'])
660661

661662
assert icsys.input_labels == ['u[0]', 'u[1]', 'w[0]', 'w[1]']
663+
664+
665+
def test_interconnect_params():
666+
# Create a nominally unstable system
667+
sys1 = ct.nlsys(
668+
lambda t, x, u, params: params['a'] * x[0] + u[0],
669+
states=1, inputs='u', outputs='y', params={'a': 1})
670+
671+
# Simple system for serial interconnection
672+
sys2 = ct.nlsys(
673+
None, lambda t, x, u, params: u[0],
674+
inputs='r', outputs='u')
675+
676+
# Create a series interconnection
677+
sys = ct.interconnect([sys1, sys2], inputs='r', outputs='y')
678+
679+
# Make sure we can call the update function
680+
sys.updfcn(0, [0], [0], {})
681+
682+
# Make sure the serial interconnection is unstable to start
683+
assert sys.linearize([0], [0]).poles()[0].real == 1
684+
685+
# Change the parameter and make sure it takes
686+
assert sys.linearize([0], [0], params={'a': -1}).poles()[0].real == -1
687+
688+
# Now try running a simulation
689+
timepts = np.linspace(0, 10)
690+
resp = ct.input_output_response(sys, timepts, 0, params={'a': -1})
691+
assert resp.states[0, -1].item() < 2 * math.exp(-10)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy