pathsim 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pathsim/__init__.py +3 -0
- pathsim/blocks/__init__.py +14 -0
- pathsim/blocks/_block.py +209 -0
- pathsim/blocks/adder.py +30 -0
- pathsim/blocks/amplifier.py +34 -0
- pathsim/blocks/delay.py +70 -0
- pathsim/blocks/differentiator.py +70 -0
- pathsim/blocks/function.py +82 -0
- pathsim/blocks/integrator.py +66 -0
- pathsim/blocks/lti.py +155 -0
- pathsim/blocks/multiplier.py +30 -0
- pathsim/blocks/ode.py +86 -0
- pathsim/blocks/rf/__init__.py +4 -0
- pathsim/blocks/rf/filters.py +169 -0
- pathsim/blocks/rf/noise.py +218 -0
- pathsim/blocks/rf/sources.py +163 -0
- pathsim/blocks/rf/wienerhammerstein.py +338 -0
- pathsim/blocks/rng.py +57 -0
- pathsim/blocks/scope.py +224 -0
- pathsim/blocks/sources.py +71 -0
- pathsim/blocks/spectrum.py +316 -0
- pathsim/connection.py +112 -0
- pathsim/simulation.py +652 -0
- pathsim/solvers/__init__.py +25 -0
- pathsim/solvers/_solver.py +403 -0
- pathsim/solvers/bdf.py +240 -0
- pathsim/solvers/dirk2.py +101 -0
- pathsim/solvers/dirk3.py +86 -0
- pathsim/solvers/esdirk32.py +131 -0
- pathsim/solvers/esdirk4.py +99 -0
- pathsim/solvers/esdirk43.py +139 -0
- pathsim/solvers/esdirk54.py +141 -0
- pathsim/solvers/esdirk85.py +200 -0
- pathsim/solvers/euler.py +81 -0
- pathsim/solvers/rk4.py +61 -0
- pathsim/solvers/rkbs32.py +101 -0
- pathsim/solvers/rkck54.py +108 -0
- pathsim/solvers/rkdp54.py +111 -0
- pathsim/solvers/rkdp87.py +116 -0
- pathsim/solvers/rkf45.py +102 -0
- pathsim/solvers/rkf78.py +111 -0
- pathsim/solvers/rkv65.py +103 -0
- pathsim/solvers/ssprk22.py +62 -0
- pathsim/solvers/ssprk33.py +65 -0
- pathsim/solvers/ssprk34.py +74 -0
- pathsim/subsystem.py +267 -0
- pathsim/utils/__init__.py +0 -0
- pathsim/utils/adaptivebuffer.py +87 -0
- pathsim/utils/anderson.py +180 -0
- pathsim/utils/funcs.py +205 -0
- pathsim/utils/gilbert.py +110 -0
- pathsim/utils/progresstracker.py +90 -0
- pathsim/utils/realtimeplotter.py +230 -0
- pathsim/utils/statespacerealizations.py +116 -0
- pathsim/utils/waveforms.py +36 -0
- pathsim-0.2.0.dist-info/LICENSE.txt +21 -0
- pathsim-0.2.0.dist-info/METADATA +149 -0
- pathsim-0.2.0.dist-info/RECORD +109 -0
- pathsim-0.2.0.dist-info/WHEEL +5 -0
- pathsim-0.2.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/blocks/__init__.py +0 -0
- tests/blocks/test_adder.py +85 -0
- tests/blocks/test_amplifier.py +66 -0
- tests/blocks/test_block.py +138 -0
- tests/blocks/test_delay.py +122 -0
- tests/blocks/test_differentiator.py +102 -0
- tests/blocks/test_function.py +165 -0
- tests/blocks/test_integrator.py +92 -0
- tests/blocks/test_lti.py +162 -0
- tests/blocks/test_multiplier.py +87 -0
- tests/blocks/test_ode.py +125 -0
- tests/blocks/test_rng.py +109 -0
- tests/blocks/test_scope.py +196 -0
- tests/blocks/test_sources.py +119 -0
- tests/blocks/test_spectrum.py +119 -0
- tests/solvers/__init__.py +0 -0
- tests/solvers/test_bdf.py +364 -0
- tests/solvers/test_dirk2.py +138 -0
- tests/solvers/test_dirk3.py +137 -0
- tests/solvers/test_esdirk32.py +158 -0
- tests/solvers/test_esdirk4.py +138 -0
- tests/solvers/test_esdirk43.py +158 -0
- tests/solvers/test_esdirk54.py +160 -0
- tests/solvers/test_esdirk85.py +157 -0
- tests/solvers/test_euler.py +223 -0
- tests/solvers/test_rk4.py +138 -0
- tests/solvers/test_rkbs32.py +159 -0
- tests/solvers/test_rkck54.py +157 -0
- tests/solvers/test_rkdp54.py +159 -0
- tests/solvers/test_rkdp87.py +157 -0
- tests/solvers/test_rkf45.py +159 -0
- tests/solvers/test_rkf78.py +160 -0
- tests/solvers/test_rkv65.py +160 -0
- tests/solvers/test_solver.py +119 -0
- tests/solvers/test_ssprk22.py +136 -0
- tests/solvers/test_ssprk33.py +136 -0
- tests/solvers/test_ssprk34.py +136 -0
- tests/test_connection.py +176 -0
- tests/test_simulation.py +271 -0
- tests/test_subsystem.py +182 -0
- tests/utils/__init__.py +0 -0
- tests/utils/test_adaptivebuffer.py +111 -0
- tests/utils/test_anderson.py +142 -0
- tests/utils/test_funcs.py +143 -0
- tests/utils/test_gilbert.py +108 -0
- tests/utils/test_progresstracker.py +144 -0
- tests/utils/test_realtimeplotter.py +122 -0
- tests/utils/test_statespacerealizations.py +107 -0
pathsim/connection.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#########################################################################################
|
|
2
|
+
##
|
|
3
|
+
## CONNECTION CLASS (connection.py)
|
|
4
|
+
##
|
|
5
|
+
## This module implements the 'Connection' class that transfers
|
|
6
|
+
## data between the blocks and their input/output channels
|
|
7
|
+
##
|
|
8
|
+
## Milan Rother 2023/24
|
|
9
|
+
##
|
|
10
|
+
#########################################################################################
|
|
11
|
+
|
|
12
|
+
# IMPORTS ===============================================================================
|
|
13
|
+
|
|
14
|
+
#no dependencies
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# CLASSES ===============================================================================
|
|
18
|
+
|
|
19
|
+
class Connection:
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
Class to handle input-output relations of blocks by connecting
|
|
23
|
+
them (directed graph) and transfering data from the output port
|
|
24
|
+
of the source block to the input port of the target block.
|
|
25
|
+
|
|
26
|
+
The default ports for connection are (0) -> (0), since these
|
|
27
|
+
are the default inputs that are used in the SISO blocks.
|
|
28
|
+
|
|
29
|
+
EXAMPLE:
|
|
30
|
+
|
|
31
|
+
Lets assume we have two generic blocks
|
|
32
|
+
|
|
33
|
+
B1 = Block...
|
|
34
|
+
B2 = Block...
|
|
35
|
+
|
|
36
|
+
that we want to connect. We initialize a 'Connection'
|
|
37
|
+
with the blocks directly as the arguments if we want to
|
|
38
|
+
connect the default ports (0) -> (0)
|
|
39
|
+
|
|
40
|
+
C = Connection(B1, B2)
|
|
41
|
+
|
|
42
|
+
which is a connection from block 'B1' to 'B2'. If we want
|
|
43
|
+
to explicitly declare the input and output ports we can do
|
|
44
|
+
that by giving tuples (lists also work) as the arguments
|
|
45
|
+
|
|
46
|
+
C = Connection((B1, 0), (B2, 0))
|
|
47
|
+
|
|
48
|
+
which is exactly the default port setup. Connecting output
|
|
49
|
+
port (1) of 'B1' to the default input port (0) of 'B2' do
|
|
50
|
+
|
|
51
|
+
C = Connection((B1, 1), (B2, 0))
|
|
52
|
+
|
|
53
|
+
or just
|
|
54
|
+
|
|
55
|
+
C = Connection((B1, 1), B2).
|
|
56
|
+
|
|
57
|
+
The 'Connection' class also supports multiple targets for
|
|
58
|
+
a single source. This is specified by just adding more blocks
|
|
59
|
+
with their respective ports into the constructor like this:
|
|
60
|
+
|
|
61
|
+
C = Connection(B1, (B2,0), (B2,1), B3, ...)
|
|
62
|
+
|
|
63
|
+
The port definitions follow the same structure as for
|
|
64
|
+
single target connections.
|
|
65
|
+
|
|
66
|
+
'self'-connections also work without a problem. This is useful
|
|
67
|
+
for modeling direct feedback of a block to itself.
|
|
68
|
+
|
|
69
|
+
INPUTS:
|
|
70
|
+
source : (tuple ('Block', int) OR 'Block') source block and optional source output port
|
|
71
|
+
targets : (tuples of ('Block' int) OR multiple 'Block's) target blocks and optional target input ports
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
def __init__(self, source, *targets):
|
|
75
|
+
|
|
76
|
+
#assign source block and port
|
|
77
|
+
self.source = source if isinstance(source, (list, tuple)) else (source, 0)
|
|
78
|
+
|
|
79
|
+
#assign target blocks and ports
|
|
80
|
+
self.targets = [trg if isinstance(trg, (list, tuple)) else (trg, 0) for trg in targets]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def overwrites(self, other):
|
|
84
|
+
"""
|
|
85
|
+
Check if the connection 'self' overwrites the target port
|
|
86
|
+
of connection 'other' and return 'True' if so.
|
|
87
|
+
|
|
88
|
+
INPUTS:
|
|
89
|
+
other : ('Connection' instance) other connection to check
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
#catch self checking
|
|
93
|
+
if self == other:
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
#iterate all targets
|
|
97
|
+
for trg in self.targets:
|
|
98
|
+
#check if there is target and port overlap
|
|
99
|
+
if trg in other.targets:
|
|
100
|
+
return True
|
|
101
|
+
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def update(self):
|
|
106
|
+
"""
|
|
107
|
+
Transfers data from the source block output port
|
|
108
|
+
to the target block input port.
|
|
109
|
+
"""
|
|
110
|
+
val = self.source[0].get(self.source[1])
|
|
111
|
+
for trg, prt in self.targets:
|
|
112
|
+
trg.set(prt, val)
|