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.
Files changed (109) hide show
  1. pathsim/__init__.py +3 -0
  2. pathsim/blocks/__init__.py +14 -0
  3. pathsim/blocks/_block.py +209 -0
  4. pathsim/blocks/adder.py +30 -0
  5. pathsim/blocks/amplifier.py +34 -0
  6. pathsim/blocks/delay.py +70 -0
  7. pathsim/blocks/differentiator.py +70 -0
  8. pathsim/blocks/function.py +82 -0
  9. pathsim/blocks/integrator.py +66 -0
  10. pathsim/blocks/lti.py +155 -0
  11. pathsim/blocks/multiplier.py +30 -0
  12. pathsim/blocks/ode.py +86 -0
  13. pathsim/blocks/rf/__init__.py +4 -0
  14. pathsim/blocks/rf/filters.py +169 -0
  15. pathsim/blocks/rf/noise.py +218 -0
  16. pathsim/blocks/rf/sources.py +163 -0
  17. pathsim/blocks/rf/wienerhammerstein.py +338 -0
  18. pathsim/blocks/rng.py +57 -0
  19. pathsim/blocks/scope.py +224 -0
  20. pathsim/blocks/sources.py +71 -0
  21. pathsim/blocks/spectrum.py +316 -0
  22. pathsim/connection.py +112 -0
  23. pathsim/simulation.py +652 -0
  24. pathsim/solvers/__init__.py +25 -0
  25. pathsim/solvers/_solver.py +403 -0
  26. pathsim/solvers/bdf.py +240 -0
  27. pathsim/solvers/dirk2.py +101 -0
  28. pathsim/solvers/dirk3.py +86 -0
  29. pathsim/solvers/esdirk32.py +131 -0
  30. pathsim/solvers/esdirk4.py +99 -0
  31. pathsim/solvers/esdirk43.py +139 -0
  32. pathsim/solvers/esdirk54.py +141 -0
  33. pathsim/solvers/esdirk85.py +200 -0
  34. pathsim/solvers/euler.py +81 -0
  35. pathsim/solvers/rk4.py +61 -0
  36. pathsim/solvers/rkbs32.py +101 -0
  37. pathsim/solvers/rkck54.py +108 -0
  38. pathsim/solvers/rkdp54.py +111 -0
  39. pathsim/solvers/rkdp87.py +116 -0
  40. pathsim/solvers/rkf45.py +102 -0
  41. pathsim/solvers/rkf78.py +111 -0
  42. pathsim/solvers/rkv65.py +103 -0
  43. pathsim/solvers/ssprk22.py +62 -0
  44. pathsim/solvers/ssprk33.py +65 -0
  45. pathsim/solvers/ssprk34.py +74 -0
  46. pathsim/subsystem.py +267 -0
  47. pathsim/utils/__init__.py +0 -0
  48. pathsim/utils/adaptivebuffer.py +87 -0
  49. pathsim/utils/anderson.py +180 -0
  50. pathsim/utils/funcs.py +205 -0
  51. pathsim/utils/gilbert.py +110 -0
  52. pathsim/utils/progresstracker.py +90 -0
  53. pathsim/utils/realtimeplotter.py +230 -0
  54. pathsim/utils/statespacerealizations.py +116 -0
  55. pathsim/utils/waveforms.py +36 -0
  56. pathsim-0.2.0.dist-info/LICENSE.txt +21 -0
  57. pathsim-0.2.0.dist-info/METADATA +149 -0
  58. pathsim-0.2.0.dist-info/RECORD +109 -0
  59. pathsim-0.2.0.dist-info/WHEEL +5 -0
  60. pathsim-0.2.0.dist-info/top_level.txt +2 -0
  61. tests/__init__.py +0 -0
  62. tests/blocks/__init__.py +0 -0
  63. tests/blocks/test_adder.py +85 -0
  64. tests/blocks/test_amplifier.py +66 -0
  65. tests/blocks/test_block.py +138 -0
  66. tests/blocks/test_delay.py +122 -0
  67. tests/blocks/test_differentiator.py +102 -0
  68. tests/blocks/test_function.py +165 -0
  69. tests/blocks/test_integrator.py +92 -0
  70. tests/blocks/test_lti.py +162 -0
  71. tests/blocks/test_multiplier.py +87 -0
  72. tests/blocks/test_ode.py +125 -0
  73. tests/blocks/test_rng.py +109 -0
  74. tests/blocks/test_scope.py +196 -0
  75. tests/blocks/test_sources.py +119 -0
  76. tests/blocks/test_spectrum.py +119 -0
  77. tests/solvers/__init__.py +0 -0
  78. tests/solvers/test_bdf.py +364 -0
  79. tests/solvers/test_dirk2.py +138 -0
  80. tests/solvers/test_dirk3.py +137 -0
  81. tests/solvers/test_esdirk32.py +158 -0
  82. tests/solvers/test_esdirk4.py +138 -0
  83. tests/solvers/test_esdirk43.py +158 -0
  84. tests/solvers/test_esdirk54.py +160 -0
  85. tests/solvers/test_esdirk85.py +157 -0
  86. tests/solvers/test_euler.py +223 -0
  87. tests/solvers/test_rk4.py +138 -0
  88. tests/solvers/test_rkbs32.py +159 -0
  89. tests/solvers/test_rkck54.py +157 -0
  90. tests/solvers/test_rkdp54.py +159 -0
  91. tests/solvers/test_rkdp87.py +157 -0
  92. tests/solvers/test_rkf45.py +159 -0
  93. tests/solvers/test_rkf78.py +160 -0
  94. tests/solvers/test_rkv65.py +160 -0
  95. tests/solvers/test_solver.py +119 -0
  96. tests/solvers/test_ssprk22.py +136 -0
  97. tests/solvers/test_ssprk33.py +136 -0
  98. tests/solvers/test_ssprk34.py +136 -0
  99. tests/test_connection.py +176 -0
  100. tests/test_simulation.py +271 -0
  101. tests/test_subsystem.py +182 -0
  102. tests/utils/__init__.py +0 -0
  103. tests/utils/test_adaptivebuffer.py +111 -0
  104. tests/utils/test_anderson.py +142 -0
  105. tests/utils/test_funcs.py +143 -0
  106. tests/utils/test_gilbert.py +108 -0
  107. tests/utils/test_progresstracker.py +144 -0
  108. tests/utils/test_realtimeplotter.py +122 -0
  109. 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)