diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index ee64cf3..6680993 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -162,5 +162,27 @@ } }, "active": "0ba8a1b9b9dd949a", - "lastOpenFiles": [] + "lastOpenFiles": [ + "src/models/active_inference/dispatcher.py", + "Things/Continuous_Generic/__pycache__/test_continuous_generic.cpython-310-pytest-8.3.2.pyc", + "Things/Continuous_Generic/__pycache__/conftest.cpython-310-pytest-8.3.2.pyc", + "Things/Continuous_Generic/Output/tests/single_step", + "Things/Continuous_Generic/Output/tests/multi_step", + "Things/Continuous_Generic/Output/tests/complex", + "Things/Continuous_Generic/Output/tests/basic", + "Things/Continuous_Generic/Output/tests", + "Things/Continuous_Generic/Output", + "Things/Continuous_Generic/__pycache__/visualization.cpython-310.pyc", + "Things/Continuous_Generic/__pycache__/continuous_generic.cpython-310.pyc", + "Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_evolution.gif", + "Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_analysis.png", + "Things/Continuous_Generic/Output/tests/complex/taylor_prediction/prediction_analysis.png", + "Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/error_analysis.png", + "Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/derivative_analysis.png", + "Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/generalized_coordinates.gif", + "Things/Continuous_Generic/Output/tests/complex/driven_oscillator/prediction_analysis.png", + "Things/Continuous_Generic/Output/tests/complex/driven_oscillator/state_correlations.png", + "Things/Continuous_Generic/Output/tests/complex/driven_oscillator/time_evolution.png", + "Things/Continuous_Generic/Output/tests/complex/driven_oscillator/phase_space.png" + ] } \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/basic/sensory_mapping/data.json b/Things/Continuous_Generic/Output/tests/basic/sensory_mapping/data.json new file mode 100644 index 0000000..7b8693f --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/basic/sensory_mapping/data.json @@ -0,0 +1,100 @@ +{ + "test_cases": [ + [ + 0.1, + 0.2 + ], + [ + 0.01, + 0.02 + ], + [ + 0.0, + 0.0 + ], + [ + -0.1, + 0.1 + ], + [ + 1.0, + 1.0 + ] + ], + "results": [ + { + "input": [ + 0.1, + 0.2 + ], + "output": [ + 0.10250000000000001, + 0.20400000000000001 + ], + "ratio": [ + 1.025, + 1.02 + ], + "scale_factor": 1.0225 + }, + { + "input": [ + 0.01, + 0.02 + ], + "output": [ + 0.010025, + 0.02004 + ], + "ratio": [ + 1.0025, + 1.002 + ], + "scale_factor": 1.00225 + }, + { + "input": [ + 0.0, + 0.0 + ], + "output": [ + 0.0, + 0.0 + ], + "ratio": null, + "scale_factor": null + }, + { + "input": [ + -0.1, + 0.1 + ], + "output": [ + -0.1005, + 0.0995 + ], + "ratio": [ + 1.005, + 0.995 + ], + "scale_factor": 1.0 + }, + { + "input": [ + 1.0, + 1.0 + ], + "output": [ + 1.1500000000000001, + 1.1500000000000001 + ], + "ratio": [ + 1.1500000000000001, + 1.1500000000000001 + ], + "scale_factor": 1.1500000000000001 + } + ], + "mean_scale": 1.0436875, + "scale_std": 0.06200185859109391 +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/basic/sensory_mapping/sensory_mapping_analysis.png b/Things/Continuous_Generic/Output/tests/basic/sensory_mapping/sensory_mapping_analysis.png new file mode 100644 index 0000000..c6f41e1 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/basic/sensory_mapping/sensory_mapping_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/basic/shift_operator/data.json b/Things/Continuous_Generic/Output/tests/basic/shift_operator/data.json new file mode 100644 index 0000000..7ca5179 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/basic/shift_operator/data.json @@ -0,0 +1,29 @@ +{ + "operator": [ + [ + 0.0, + 1.0, + 0.0 + ], + [ + 0.0, + 0.0, + 2.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + "input": [ + 1.0, + 2.0, + 3.0 + ], + "output": [ + 2.0, + 6.0, + 0.0 + ] +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/data.json b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/data.json new file mode 100644 index 0000000..d0657b3 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/data.json @@ -0,0 +1,2408 @@ +{ + "state_history": [ + [ + [ + -1.9468721051745855e-30, + 0.0, + 0.0 + ], + [ + -1.9468721051745855e-30, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0 + ] + ] + ], + "drive_history": [ + [ + 0.0, + 0.0 + ], + [ + 3.999999998933334e-08, + 0.0 + ], + [ + 7.999999991466667e-08, + 0.0 + ], + [ + 1.1999999971200003e-07, + 0.0 + ], + [ + 1.5999999931733335e-07, + 0.0 + ], + [ + 1.999999986666667e-07, + 0.0 + ], + [ + 2.3999999769600006e-07, + 0.0 + ], + [ + 2.799999963413334e-07, + 0.0 + ], + [ + 3.199999945386667e-07, + 0.0 + ], + [ + 3.5999999222400016e-07, + 0.0 + ], + [ + 3.999999893333334e-07, + 0.0 + ], + [ + 4.3999998580266686e-07, + 0.0 + ], + [ + 4.799999815680003e-07, + 0.0 + ], + [ + 5.199999765653337e-07, + 0.0 + ], + [ + 5.599999707306673e-07, + 0.0 + ], + [ + 5.999999640000008e-07, + 0.0 + ], + [ + 6.399999563093343e-07, + 0.0 + ], + [ + 6.799999475946679e-07, + 0.0 + ], + [ + 7.199999377920017e-07, + 0.0 + ], + [ + 7.599999268373356e-07, + 0.0 + ], + [ + 7.999999146666695e-07, + 0.0 + ], + [ + 8.399999012160036e-07, + 0.0 + ], + [ + 8.799998864213379e-07, + 0.0 + ], + [ + 9.199998702186722e-07, + 0.0 + ], + [ + 9.59999852544007e-07, + 0.0 + ], + [ + 9.999998333333416e-07, + 0.0 + ], + [ + 1.039999812522677e-06, + 0.0 + ], + [ + 1.0799997900480123e-06, + 0.0 + ], + [ + 1.1199997658453482e-06, + 0.0 + ], + [ + 1.1599997398506844e-06, + 0.0 + ], + [ + 1.1999997120000207e-06, + 0.0 + ], + [ + 1.239999682229358e-06, + 0.0 + ], + [ + 1.2799996504746953e-06, + 0.0 + ], + [ + 1.3199996166720333e-06, + 0.0 + ], + [ + 1.3599995807573722e-06, + 0.0 + ], + [ + 1.3999995426667119e-06, + 0.0 + ], + [ + 1.439999502336052e-06, + 0.0 + ], + [ + 1.4799994597013927e-06, + 0.0 + ], + [ + 1.5199994146987343e-06, + 0.0 + ], + [ + 1.5599993672640774e-06, + 0.0 + ], + [ + 1.5999993173334209e-06, + 0.0 + ], + [ + 1.6399992648427656e-06, + 0.0 + ], + [ + 1.6799992097281118e-06, + 0.0 + ], + [ + 1.7199991519254591e-06, + 0.0 + ], + [ + 1.7599990913708078e-06, + 0.0 + ], + [ + 1.7999990280001578e-06, + 0.0 + ], + [ + 1.839998961749509e-06, + 0.0 + ], + [ + 1.8799988925548627e-06, + 0.0 + ], + [ + 1.9199988203522177e-06, + 0.0 + ], + [ + 1.9599987450775745e-06, + 0.0 + ], + [ + 1.9999986666669334e-06, + 0.0 + ], + [ + 2.0399985850562945e-06, + 0.0 + ], + [ + 2.0799985001816577e-06, + 0.0 + ], + [ + 2.1199984119790234e-06, + 0.0 + ], + [ + 2.159998320384392e-06, + 0.0 + ], + [ + 2.1999982253337627e-06, + 0.0 + ], + [ + 2.239998126763137e-06, + 0.0 + ], + [ + 2.2799980246085138e-06, + 0.0 + ], + [ + 2.319997918805894e-06, + 0.0 + ], + [ + 2.3599978092912767e-06, + 0.0 + ], + [ + 2.399997696000664e-06, + 0.0 + ], + [ + 2.4399975788700547e-06, + 0.0 + ], + [ + 2.479997457835449e-06, + 0.0 + ], + [ + 2.5199973328328473e-06, + 0.0 + ], + [ + 2.5599972037982495e-06, + 0.0 + ], + [ + 2.5999970706676575e-06, + 0.0 + ], + [ + 2.639996933377069e-06, + 0.0 + ], + [ + 2.6799967918624854e-06, + 0.0 + ], + [ + 2.719996646059908e-06, + 0.0 + ], + [ + 2.759996495905335e-06, + 0.0 + ], + [ + 2.7999963413347682e-06, + 0.0 + ], + [ + 2.839996182284207e-06, + 0.0 + ], + [ + 2.879996018689652e-06, + 0.0 + ], + [ + 2.9199958504871024e-06, + 0.0 + ], + [ + 2.9599956776125606e-06, + 0.0 + ], + [ + 2.9999955000020255e-06, + 0.0 + ], + [ + 3.039995317591497e-06, + 0.0 + ], + [ + 3.0799951303169767e-06, + 0.0 + ], + [ + 3.1199949381144645e-06, + 0.0 + ], + [ + 3.1599947409199597e-06, + 0.0 + ], + [ + 3.1999945386694632e-06, + 0.0 + ], + [ + 3.2399943312989753e-06, + 0.0 + ], + [ + 3.2799941187444975e-06, + 0.0 + ], + [ + 3.319993900942028e-06, + 0.0 + ], + [ + 3.3599936778275692e-06, + 0.0 + ], + [ + 3.3999934493371203e-06, + 0.0 + ], + [ + 3.4399932154066814e-06, + 0.0 + ], + [ + 3.4799929759722534e-06, + 0.0 + ], + [ + 3.5199927309698373e-06, + 0.0 + ], + [ + 3.5599924803354323e-06, + 0.0 + ], + [ + 3.5999922240050394e-06, + 0.0 + ], + [ + 3.639991961914659e-06, + 0.0 + ], + [ + 3.679991694000291e-06, + 0.0 + ], + [ + 3.7199914201979374e-06, + 0.0 + ], + [ + 3.7599911404435963e-06, + 0.0 + ], + [ + 3.7999908546732698e-06, + 0.0 + ], + [ + 3.8399905628229585e-06, + 0.0 + ], + [ + 3.879990264828661e-06, + 0.0 + ], + [ + 3.919989960626381e-06, + 0.0 + ], + [ + 3.959989650152116e-06, + 0.0 + ], + [ + 3.999989333341867e-06, + 0.0 + ], + [ + 4.0399890101316366e-06, + 0.0 + ], + [ + 4.079988680457422e-06, + 0.0 + ], + [ + 4.119988344255227e-06, + 0.0 + ], + [ + 4.159988001461049e-06, + 0.0 + ], + [ + 4.199987652010892e-06, + 0.0 + ], + [ + 4.2399872958407524e-06, + 0.0 + ], + [ + 4.279986932886635e-06, + 0.0 + ], + [ + 4.319986563084539e-06, + 0.0 + ], + [ + 4.359986186370463e-06, + 0.0 + ], + [ + 4.399985802680411e-06, + 0.0 + ], + [ + 4.43998541195038e-06, + 0.0 + ], + [ + 4.4799850141163725e-06, + 0.0 + ], + [ + 4.5199846091143896e-06, + 0.0 + ], + [ + 4.559984196880431e-06, + 0.0 + ], + [ + 4.599983777350497e-06, + 0.0 + ], + [ + 4.639983350460591e-06, + 0.0 + ], + [ + 4.679982916146709e-06, + 0.0 + ], + [ + 4.719982474344856e-06, + 0.0 + ], + [ + 4.75998202499103e-06, + 0.0 + ], + [ + 4.799981568021234e-06, + 0.0 + ], + [ + 4.839981103371467e-06, + 0.0 + ], + [ + 4.87998063097773e-06, + 0.0 + ], + [ + 4.919980150776025e-06, + 0.0 + ], + [ + 4.959979662702351e-06, + 0.0 + ], + [ + 4.999979166692709e-06, + 0.0 + ], + [ + 5.039978662683101e-06, + 0.0 + ], + [ + 5.079978150609528e-06, + 0.0 + ], + [ + 5.1199776304079875e-06, + 0.0 + ], + [ + 5.159977102014484e-06, + 0.0 + ], + [ + 5.199976565365018e-06, + 0.0 + ], + [ + 5.239976020395589e-06, + 0.0 + ], + [ + 5.279975467042197e-06, + 0.0 + ], + [ + 5.319974905240847e-06, + 0.0 + ], + [ + 5.359974334927535e-06, + 0.0 + ], + [ + 5.399973756038264e-06, + 0.0 + ], + [ + 5.439973168509036e-06, + 0.0 + ], + [ + 5.479972572275851e-06, + 0.0 + ], + [ + 5.51997196727471e-06, + 0.0 + ], + [ + 5.559971353441612e-06, + 0.0 + ], + [ + 5.5999707307125615e-06, + 0.0 + ], + [ + 5.639970099023558e-06, + 0.0 + ], + [ + 5.6799694583106025e-06, + 0.0 + ], + [ + 5.719968808509694e-06, + 0.0 + ], + [ + 5.759968149556837e-06, + 0.0 + ], + [ + 5.79996748138803e-06, + 0.0 + ], + [ + 5.839966803939276e-06, + 0.0 + ], + [ + 5.879966117146575e-06, + 0.0 + ], + [ + 5.919965420945928e-06, + 0.0 + ], + [ + 5.9599647152733355e-06, + 0.0 + ] + ], + "drive_frequency": 0.2, + "drive_amplitude": 0.001 +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/phase_space.png b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/phase_space.png new file mode 100644 index 0000000..9813a9b Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/phase_space.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/prediction_analysis.png b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/prediction_analysis.png new file mode 100644 index 0000000..883fec7 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/prediction_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/state_correlations.png b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/state_correlations.png new file mode 100644 index 0000000..748f98d Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/state_correlations.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/time_evolution.png b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/time_evolution.png new file mode 100644 index 0000000..8d16023 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/driven_oscillator/time_evolution.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_analysis.png b/Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_analysis.png new file mode 100644 index 0000000..715969c Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_evolution.gif b/Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_evolution.gif new file mode 100644 index 0000000..354462a Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/energy_conservation/energy_evolution.gif differ diff --git a/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/derivative_analysis.png b/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/derivative_analysis.png new file mode 100644 index 0000000..c8aea40 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/derivative_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/error_analysis.png b/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/error_analysis.png new file mode 100644 index 0000000..4d54893 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/error_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/generalized_coordinates.gif b/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/generalized_coordinates.gif new file mode 100644 index 0000000..1b900bd Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/generalized_coordinates/generalized_coordinates.gif differ diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/data.json b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/data.json new file mode 100644 index 0000000..5435620 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/data.json @@ -0,0 +1,1511 @@ +{ + "state_history": [ + [ + [ + 0.009999999963636555, + -4.152020571197563e-07, + -0.0005 + ], + [ + 2.0760102855987782e-06, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999999373731418, + -1.2456061713592688e-06, + -0.0005 + ], + [ + 6.228030856796311e-06, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999999809425529, + -2.076010285598782e-06, + -0.0005 + ], + [ + 1.0380051427993829e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999996125208169, + -2.9064143998382976e-06, + -0.0005 + ], + [ + 1.4532071999191325e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999993466590055, + -3.7368185140778148e-06, + -0.0005 + ], + [ + 1.8684092570388752e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999990118400947, + -4.567222628317337e-06, + -0.0005 + ], + [ + 2.2836113141586143e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999986080640852, + -5.397626742556859e-06, + -0.0005 + ], + [ + 2.6988133712783497e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999998135330976, + -6.228030856796382e-06, + -0.0005 + ], + [ + 3.114015428398082e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999975936407673, + -7.058434971035904e-06, + -0.0005 + ], + [ + 3.529217485517798e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999996982993459, + -7.888839085275425e-06, + -0.0005 + ], + [ + 3.944419542637509e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999963033890518, + -8.719243199514935e-06, + -0.0005 + ], + [ + 4.359621599757217e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999955548275452, + -9.549647313754413e-06, + -0.0005 + ], + [ + 4.774823656876924e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999947373089395, + -1.0380051427993892e-05, + -0.0005 + ], + [ + 5.1900257139966256e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999993850833235, + -1.121045554223337e-05, + -0.0005 + ], + [ + 5.6052277711163234e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999928954004308, + -1.2040859656472848e-05, + -0.0005 + ], + [ + 6.020429828236017e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999918710105271, + -1.2871263770712326e-05, + -0.0005 + ], + [ + 6.435631885355721e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999907776635241, + -1.3701667884951805e-05, + -0.0005 + ], + [ + 6.85083394247542e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999896153594218, + -1.453207199919129e-05, + -0.0005 + ], + [ + 7.266035999595117e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999883840982202, + -1.5362476113430788e-05, + -0.0005 + ], + [ + 7.681238056714812e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999987083879919, + -1.6192880227670307e-05, + -0.0005 + ], + [ + 8.096440113834505e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999985714704519, + -1.7023284341909826e-05, + -0.0005 + ], + [ + 8.511642170954194e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999842765720194, + -1.7853688456149345e-05, + -0.0005 + ], + [ + 8.926844228073874e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999827694824208, + -1.8684092570388864e-05, + -0.0005 + ], + [ + 9.342046285193553e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999811934357226, + -1.9514496684628383e-05, + -0.0005 + ], + [ + 9.75724834231323e-05, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999795484319255, + -2.03449007988679e-05, + -0.0005 + ], + [ + 0.00010172450399432906, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999778344710289, + -2.117530491310742e-05, + -0.0005 + ], + [ + 0.00010587652456552578, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999760515530328, + -2.200570902734694e-05, + -0.0005 + ], + [ + 0.00011002854513672249, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999741996779379, + -2.283611314158646e-05, + -0.0005 + ], + [ + 0.00011418056570791917, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999722788457439, + -2.3666517255825977e-05, + -0.0005 + ], + [ + 0.00011833258627911578, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999702890564503, + -2.4496921370065496e-05, + -0.0005 + ], + [ + 0.00012248460685031237, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999682303100572, + -2.5327325484305015e-05, + -0.0005 + ], + [ + 0.0001266366274215089, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999661026065646, + -2.6157729598544534e-05, + -0.0005 + ], + [ + 0.00013078864799270543, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999639059459726, + -2.6988133712784053e-05, + -0.0005 + ], + [ + 0.00013494066856390192, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999616403282818, + -2.7818537827023572e-05, + -0.0005 + ], + [ + 0.00013909268913509835, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999593057534915, + -2.864894194126309e-05, + -0.0005 + ], + [ + 0.00014324470970629476, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999569022216019, + -2.947934605550261e-05, + -0.0005 + ], + [ + 0.00014739673027749114, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999954429732613, + -3.0309750169742105e-05, + -0.0005 + ], + [ + 0.00015154875084868753, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999518882865249, + -3.114015428398161e-05, + -0.0005 + ], + [ + 0.00015570077141988388, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999492778833373, + -3.197055839822119e-05, + -0.0005 + ], + [ + 0.00015985279199108018, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999465985230506, + -3.280096251246084e-05, + -0.0005 + ], + [ + 0.00016400481256227637, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999438502056647, + -3.3631366626700486e-05, + -0.0005 + ], + [ + 0.00016815683313347254, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999410329311797, + -3.446177074094013e-05, + -0.0005 + ], + [ + 0.00017230885370466868, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999938146699595, + -3.529217485517978e-05, + -0.0005 + ], + [ + 0.00017646087427586479, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999351915109108, + -3.612257896941943e-05, + -0.0005 + ], + [ + 0.00018061289484706084, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999321673651277, + -3.6952983083659076e-05, + -0.0005 + ], + [ + 0.0001847649154182569, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999290742622452, + -3.7783387197898724e-05, + -0.0005 + ], + [ + 0.00018891693598945287, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999259122022633, + -3.861379131213837e-05, + -0.0005 + ], + [ + 0.00019306895656064882, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999226811851824, + -3.944419542637802e-05, + -0.0005 + ], + [ + 0.00019722097713184477, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999193812110022, + -4.027459954061767e-05, + -0.0005 + ], + [ + 0.00020137299770304072, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999160122797224, + -4.1105003654857314e-05, + -0.0005 + ], + [ + 0.0002055250182742366, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999125743913434, + -4.193540776909696e-05, + -0.0005 + ], + [ + 0.0002096770388454325, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999909067545865, + -4.276581188333661e-05, + -0.0005 + ], + [ + 0.00021382905941662837, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999054917432873, + -4.359621599757626e-05, + -0.0005 + ], + [ + 0.0002179810799878242, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009999018469836102, + -4.4426620111815905e-05, + -0.0005 + ], + [ + 0.0002221331005590199, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998981332668341, + -4.525702422605555e-05, + -0.0005 + ], + [ + 0.00022628512113021556, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998943505929588, + -4.60874283402952e-05, + -0.0005 + ], + [ + 0.00023043714170141121, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998904989619842, + -4.691783245453485e-05, + -0.0005 + ], + [ + 0.00023458916227260684, + 0.005, + 0.0 + ] + ], + [ + [ + 0.0099988657837391, + -4.7748236568774496e-05, + -0.0005 + ], + [ + 0.00023874118284380246, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998825888287365, + -4.8578640683014143e-05, + -0.0005 + ], + [ + 0.00024289320341499806, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998785303264639, + -4.940904479725379e-05, + -0.0005 + ], + [ + 0.0002470452239861943, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998744028670918, + -5.023944891149344e-05, + -0.0005 + ], + [ + 0.0002511972445573909, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999870206450621, + -5.1069853025733086e-05, + -0.0005 + ], + [ + 0.0002553492651285876, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998659410770506, + -5.1900257139972734e-05, + -0.0005 + ], + [ + 0.00025950128569978423, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998616067463809, + -5.273066125421238e-05, + -0.0005 + ], + [ + 0.00026365330627098083, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998572034586118, + -5.356106536845203e-05, + -0.0005 + ], + [ + 0.0002678053268421774, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999852731213743, + -5.439146948269168e-05, + -0.0005 + ], + [ + 0.0002719573474133739, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998481900117753, + -5.5221873596931325e-05, + -0.0005 + ], + [ + 0.00027610936798457036, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999843579852708, + -5.605227771117097e-05, + -0.0005 + ], + [ + 0.0002802613885557668, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998389007365417, + -5.688268182541062e-05, + -0.0005 + ], + [ + 0.0002844134091269631, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998341526632763, + -5.771308593965027e-05, + -0.0005 + ], + [ + 0.00028856542969815945, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998293356329117, + -5.8543490053889915e-05, + -0.0005 + ], + [ + 0.0002927174502693556, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998244496454473, + -5.937389416812956e-05, + -0.0005 + ], + [ + 0.0002968694708405517, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998194947008838, + -6.02042982823692e-05, + -0.0005 + ], + [ + 0.00030102149141174783, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998144707992209, + -6.103470239660875e-05, + -0.0005 + ], + [ + 0.00030517351198294383, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998093779404587, + -6.186510651084826e-05, + -0.0005 + ], + [ + 0.00030932553255413984, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009998042161245975, + -6.269551062508775e-05, + -0.0005 + ], + [ + 0.0003134775531253358, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997989853516371, + -6.352591473932725e-05, + -0.0005 + ], + [ + 0.0003176295736965317, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997936856215773, + -6.435631885356675e-05, + -0.0005 + ], + [ + 0.00032178159426772757, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999788316934418, + -6.518672296780625e-05, + -0.0005 + ], + [ + 0.00032593361483892346, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997828792901594, + -6.601712708204575e-05, + -0.0005 + ], + [ + 0.00033008563541011936, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997773726888013, + -6.684753119628525e-05, + -0.0005 + ], + [ + 0.00033423765598131525, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997717971303444, + -6.767793531052475e-05, + -0.0005 + ], + [ + 0.00033838967655251115, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997661526147882, + -6.850833942476424e-05, + -0.0005 + ], + [ + 0.000342541697123707, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997604391421324, + -6.933874353900374e-05, + -0.0005 + ], + [ + 0.00034669371769490277, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997546567123775, + -7.016914765324324e-05, + -0.0005 + ], + [ + 0.00035084573826609856, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999748805325523, + -7.099955176748274e-05, + -0.0005 + ], + [ + 0.00035499775883729434, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997428849815696, + -7.182995588172224e-05, + -0.0005 + ], + [ + 0.0003591497794084901, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997368956805164, + -7.266035999596174e-05, + -0.0005 + ], + [ + 0.0003633017999796859, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997308374223643, + -7.349076411020124e-05, + -0.0005 + ], + [ + 0.0003674538205508816, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997247102071128, + -7.432116822444073e-05, + -0.0005 + ], + [ + 0.00037160584112207716, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997185140347623, + -7.515157233868023e-05, + -0.0005 + ], + [ + 0.0003757578616932727, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999712248905312, + -7.598197645291973e-05, + -0.0005 + ], + [ + 0.0003799098822644683, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009997059148187626, + -7.681238056715923e-05, + -0.0005 + ], + [ + 0.00038406190283566386, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009996995117751139, + -7.764278468139873e-05, + -0.0005 + ], + [ + 0.0003882139234068593, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009996930397743659, + -7.847318879563823e-05, + -0.0005 + ], + [ + 0.0003923659439780547, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009996864988165188, + -7.930359290987773e-05, + -0.0005 + ], + [ + 0.0003965179645492499, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009996798889015723, + -8.013399702411722e-05, + -0.0005 + ], + [ + 0.0004006699851204451, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999673210029527, + -8.096440113835672e-05, + -0.0005 + ], + [ + 0.00040482200569164024, + 0.005, + 0.0 + ] + ], + [ + [ + 0.00999666462200382, + -8.179480525259622e-05, + -0.0005 + ], + [ + 0.0004089740262628354, + 0.005, + 0.0 + ] + ], + [ + [ + 0.009996596454141372, + -8.262520936683572e-05, + -0.0005 + ], + [ + 0.0004131260468340305, + 0.005, + 0.0 + ] + ] + ], + "energy_history": [ + 1.3000000104109125e-05, + 1.3000000907082355e-05, + 1.300000250306224e-05, + 1.3000004892048808e-05, + 1.3000008074042099e-05, + 1.300001204904217e-05, + 1.3000016817049087e-05, + 1.3000022378062937e-05, + 1.3000028732083813e-05, + 1.3000035879111832e-05, + 1.3000043819147117e-05, + 1.3000052552189811e-05, + 1.3000062078240068e-05, + 1.3000072397298057e-05, + 1.300008350936396e-05, + 1.3000095414437977e-05, + 1.300010811252032e-05, + 1.3000121603611211e-05, + 1.3000135887710895e-05, + 1.3000150964819626e-05, + 1.3000166834937669e-05, + 1.3000183498065314e-05, + 1.3000200954202854e-05, + 1.3000219203350601e-05, + 1.3000238245508882e-05, + 1.3000258080678037e-05, + 1.300027870885842e-05, + 1.3000300130050401e-05, + 1.3000322344254363e-05, + 1.3000345351470704e-05, + 1.3000369151699832e-05, + 1.3000393744942176e-05, + 1.3000419131198175e-05, + 1.3000445310468287e-05, + 1.3000472282752975e-05, + 1.3000500048052723e-05, + 1.3000528606368033e-05, + 1.3000557957699412e-05, + 1.3000588102047388e-05, + 1.3000619039412501e-05, + 1.3000650769795303e-05, + 1.3000683293196363e-05, + 1.3000716609616268e-05, + 1.3000750719055607e-05, + 1.3000785621515e-05, + 1.3000821316995067e-05, + 1.300085780549645e-05, + 1.3000895087019804e-05, + 1.3000933161565797e-05, + 1.3000972029135109e-05, + 1.3001011689728439e-05, + 1.3001052143346498e-05, + 1.300109338999001e-05, + 1.3001135429659718e-05, + 1.3001178262356375e-05, + 1.3001221888080746e-05, + 1.3001266306833618e-05, + 1.3001311518615785e-05, + 1.300135752342806e-05, + 1.3001404321271267e-05, + 1.3001451912146245e-05, + 1.3001500296053849e-05, + 1.3001549472994946e-05, + 1.300159944297042e-05, + 1.3001650205981167e-05, + 1.3001701762028096e-05, + 1.3001754111112134e-05, + 1.3001807253234222e-05, + 1.300186118839531e-05, + 1.300191591659637e-05, + 1.3001971437838382e-05, + 1.300202775212234e-05, + 1.3002084859449261e-05, + 1.3002142759820165e-05, + 1.3002201453236093e-05, + 1.3002260939698099e-05, + 1.300232121920725e-05, + 1.3002382291764629e-05, + 1.300244415737133e-05, + 1.3002506816028464e-05, + 1.3002570267737161e-05, + 1.3002634512498555e-05, + 1.30026995503138e-05, + 1.3002765381184065e-05, + 1.300283200511053e-05, + 1.3002899422094394e-05, + 1.3002967632136867e-05, + 1.3003036635239171e-05, + 1.300310643140255e-05, + 1.3003177020628252e-05, + 1.3003248402917546e-05, + 1.3003320578271715e-05, + 1.3003393546692056e-05, + 1.3003467308179876e-05, + 1.3003541862736503e-05, + 1.3003617210363274e-05, + 1.3003693351061543e-05, + 1.3003770284832678e-05, + 1.3003848011678057e-05, + 1.3003926531599081e-05 + ], + "kinetic_energy": [ + 1.2500000086196376e-05, + 1.2500000775767368e-05, + 1.2500002154909354e-05, + 1.2500004223622332e-05, + 1.2500006981906304e-05, + 1.250001042976127e-05, + 1.2500014567187226e-05, + 1.2500019394184178e-05, + 1.250002491075212e-05, + 1.2500031116891057e-05, + 1.2500038012600987e-05, + 1.250004559788191e-05, + 1.2500053872733825e-05, + 1.2500062837156733e-05, + 1.2500072491150634e-05, + 1.2500082834715528e-05, + 1.2500093867851416e-05, + 1.2500105590558296e-05, + 1.2500118002836168e-05, + 1.2500131104685035e-05, + 1.2500144896104893e-05, + 1.2500159377095745e-05, + 1.250017454765759e-05, + 1.2500190407790428e-05, + 1.2500206957494259e-05, + 1.2500224196769082e-05, + 1.2500242125614899e-05, + 1.2500260744031708e-05, + 1.250028005201951e-05, + 1.2500300049578307e-05, + 1.2500320736708094e-05, + 1.2500342113408877e-05, + 1.250036417968065e-05, + 1.2500386935523418e-05, + 1.2500410380937178e-05, + 1.250043451592193e-05, + 1.2500459340477676e-05, + 1.2500484854604415e-05, + 1.2500511058302147e-05, + 1.2500537951570873e-05, + 1.250056553441059e-05, + 1.2500593806821301e-05, + 1.2500622768803006e-05, + 1.2500652420355702e-05, + 1.2500682761479392e-05, + 1.2500713792174073e-05, + 1.250074551243975e-05, + 1.2500777922276418e-05, + 1.250081102168408e-05, + 1.2500844810662734e-05, + 1.2500879289212381e-05, + 1.2500914457333021e-05, + 1.2500950315024654e-05, + 1.250098686228728e-05, + 1.25010240991209e-05, + 1.2501062025525511e-05, + 1.2501100641501117e-05, + 1.2501139947047714e-05, + 1.2501179942165305e-05, + 1.250122062685389e-05, + 1.2501262001113467e-05, + 1.2501304064944036e-05, + 1.2501346818345599e-05, + 1.2501390261318154e-05, + 1.2501434393861703e-05, + 1.2501479215976244e-05, + 1.2501524727661778e-05, + 1.2501570928918306e-05, + 1.2501617819745825e-05, + 1.250166540014434e-05, + 1.2501713670113846e-05, + 1.2501762629654344e-05, + 1.2501812278765837e-05, + 1.2501862617448322e-05, + 1.25019136457018e-05, + 1.250196536352627e-05, + 1.2502017770921734e-05, + 1.2502070867888192e-05, + 1.2502124654425642e-05, + 1.2502179130534084e-05, + 1.250223429621352e-05, + 1.2502290151463948e-05, + 1.250234669628537e-05, + 1.2502403930677785e-05, + 1.2502461854641191e-05, + 1.2502520468175592e-05, + 1.2502579771280985e-05, + 1.2502639763957372e-05, + 1.250270044620475e-05, + 1.2502761818023124e-05, + 1.2502823879412489e-05, + 1.2502886630372846e-05, + 1.2502950070904198e-05, + 1.2503014201006541e-05, + 1.2503079020679879e-05, + 1.2503144529924208e-05, + 1.2503210728739531e-05, + 1.2503277617125847e-05, + 1.2503345195083156e-05, + 1.2503413462611457e-05 + ], + "potential_energy": [ + 5.000000179127492e-07, + 5.000001313149856e-07, + 5.000003481528856e-07, + 5.00000668426475e-07, + 5.00001092135795e-07, + 5.000016192809002e-07, + 5.000022498618606e-07, + 5.000029838787588e-07, + 5.000038213316928e-07, + 5.000047622207745e-07, + 5.000058065461308e-07, + 5.000069543079022e-07, + 5.000082055062435e-07, + 5.000095601413243e-07, + 5.000110182133269e-07, + 5.000125797224494e-07, + 5.000142446689036e-07, + 5.00016013052916e-07, + 5.000178848747268e-07, + 5.000198601345907e-07, + 5.000219388327771e-07, + 5.000241209695687e-07, + 5.000264065452636e-07, + 5.000287955601729e-07, + 5.000312880146234e-07, + 5.000338839089547e-07, + 5.000365832435215e-07, + 5.000393860186932e-07, + 5.000422922348528e-07, + 5.000453018923968e-07, + 5.000484149917372e-07, + 5.000516315333002e-07, + 5.000549515175255e-07, + 5.000583749448683e-07, + 5.000619018157967e-07, + 5.000655321307937e-07, + 5.000692658903568e-07, + 5.000731030949971e-07, + 5.000770437452407e-07, + 5.000810878416275e-07, + 5.000852353847119e-07, + 5.000894863750624e-07, + 5.000938408132615e-07, + 5.000982986999062e-07, + 5.001028600356086e-07, + 5.001075248209937e-07, + 5.001122930567013e-07, + 5.001171647433862e-07, + 5.001221398817163e-07, + 5.001272184723742e-07, + 5.001324005160569e-07, + 5.001376860134757e-07, + 5.00143074965356e-07, + 5.001485673724375e-07, + 5.001541632354745e-07, + 5.00159862555235e-07, + 5.001656653325018e-07, + 5.001715715680711e-07, + 5.001775812627542e-07, + 5.001836944173767e-07, + 5.00189911032778e-07, + 5.001962311098123e-07, + 5.002026546493473e-07, + 5.002091816522654e-07, + 5.002158121194632e-07, + 5.002225460518515e-07, + 5.002293834503558e-07, + 5.002363243159154e-07, + 5.002433686494842e-07, + 5.002505164520303e-07, + 5.002577677245359e-07, + 5.002651224679966e-07, + 5.002725806834241e-07, + 5.002801423718431e-07, + 5.002878075342932e-07, + 5.002955761718278e-07, + 5.003034482855148e-07, + 5.003114238764361e-07, + 5.003195029456881e-07, + 5.003276854943813e-07, + 5.003359715236407e-07, + 5.003443610346059e-07, + 5.0035285402843e-07, + 5.003614505062804e-07, + 5.003701504693394e-07, + 5.003789539188029e-07, + 5.003878608558819e-07, + 5.003968712818004e-07, + 5.004059851977982e-07, + 5.004152026051282e-07, + 5.004245235050581e-07, + 5.004339478988693e-07, + 5.004434757878583e-07, + 5.004531071733353e-07, + 5.00462842056625e-07, + 5.004726804390663e-07, + 5.004826223220121e-07, + 5.004926677068305e-07, + 5.005028165949022e-07, + 5.005130689876229e-07 + ], + "omega": 0.1 +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/energy_analysis.png b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/energy_analysis.png new file mode 100644 index 0000000..5771bf2 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/energy_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/energy_conservation.png b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/energy_conservation.png new file mode 100644 index 0000000..64b1ac4 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/energy_conservation.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/phase_space.png b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/phase_space.png new file mode 100644 index 0000000..7da8e18 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/phase_space.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/prediction_analysis.png b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/prediction_analysis.png new file mode 100644 index 0000000..94d7884 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/prediction_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/state_correlations.png b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/state_correlations.png new file mode 100644 index 0000000..ed89336 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/state_correlations.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/time_evolution.png b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/time_evolution.png new file mode 100644 index 0000000..bc6196f Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/harmonic_motion/time_evolution.png differ diff --git a/Things/Continuous_Generic/Output/tests/complex/taylor_prediction/prediction_analysis.png b/Things/Continuous_Generic/Output/tests/complex/taylor_prediction/prediction_analysis.png new file mode 100644 index 0000000..e971639 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/complex/taylor_prediction/prediction_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/data.json b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/data.json new file mode 100644 index 0000000..e94b994 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/data.json @@ -0,0 +1,148 @@ +{ + "state_history": [ + [ + [ + 0.0010002076083012311, + 0.0005000830404114237, + 0.0001 + ], + [ + -0.0009997924062441156, + 0.0004999169595885763, + -0.0001 + ] + ], + [ + [ + 0.0010004152510810118, + 0.0005001660808228474, + 0.0001 + ], + [ + -0.0009995848469667805, + 0.0004998339191771527, + -0.0001 + ] + ], + [ + [ + 0.0010006229283393419, + 0.000500249121234271, + 0.0001 + ], + [ + -0.0009993773221679953, + 0.000499750878765729, + -0.0001 + ] + ], + [ + [ + 0.0010008306400762217, + 0.0005003321616456947, + 0.0001 + ], + [ + -0.0009991698318477598, + 0.0004996678383543053, + -0.0001 + ] + ], + [ + [ + 0.0010010383862916513, + 0.0005004152020571184, + 0.0001 + ], + [ + -0.0009989623760060739, + 0.0004995847979428817, + -0.0001 + ] + ], + [ + [ + 0.0010012461669856303, + 0.000500498242468542, + 0.0001 + ], + [ + -0.0009987549546429378, + 0.000499501757531458, + -0.0001 + ] + ], + [ + [ + 0.0010014539821581589, + 0.0005005812828799657, + 0.0001 + ], + [ + -0.0009985475677583508, + 0.0004994187171200343, + -0.0001 + ] + ], + [ + [ + 0.0010016618318092372, + 0.0005006643232913894, + 0.0001 + ], + [ + -0.000998340215352314, + 0.0004993356767086106, + -0.0001 + ] + ], + [ + [ + 0.0010018697159388656, + 0.000500747363702813, + 0.0001 + ], + [ + -0.000998132897424827, + 0.000499252636297187, + -0.0001 + ] + ], + [ + [ + 0.0010020776345470433, + 0.0005008304041142367, + 0.0001 + ], + [ + -0.0009979256139758896, + 0.0004991695958857633, + -0.0001 + ] + ] + ], + "free_energy": [ + 55.26203700203595, + 55.262037002035136, + 55.26203700203414, + 55.26203700203296, + 55.26203700203158, + 55.26203700203003, + 55.262037002028286, + 55.26203700202633, + 55.262037002024215, + 55.2620370020219 + ], + "prediction_error": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ] +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/energy_diagnostics.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/energy_diagnostics.png new file mode 100644 index 0000000..fcd0ae9 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/energy_diagnostics.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/energy_distribution.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/energy_distribution.png new file mode 100644 index 0000000..55ee8ca Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/energy_distribution.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/phase_space.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/phase_space.png new file mode 100644 index 0000000..9d51aaf Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/phase_space.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/prediction_analysis.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/prediction_analysis.png new file mode 100644 index 0000000..0dd9440 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/prediction_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/prediction_error.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/prediction_error.png new file mode 100644 index 0000000..72834bb Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/prediction_error.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/state_correlations.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/state_correlations.png new file mode 100644 index 0000000..ab48f96 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/state_correlations.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/time_evolution.png b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/time_evolution.png new file mode 100644 index 0000000..ff76ac2 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/belief_evolution/time_evolution.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/convergence/data.json b/Things/Continuous_Generic/Output/tests/multi_step/convergence/data.json new file mode 100644 index 0000000..24ba868 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/multi_step/convergence/data.json @@ -0,0 +1,660 @@ +{ + "state_history": [ + [ + [ + 0.0999999991758025, + 0.0, + 0.0 + ], + [ + -0.09999999916334613, + 0.0, + 0.0 + ] + ], + [ + [ + 0.099999998351605, + 0.0, + 0.0 + ], + [ + -0.09999999832669229, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999752740753, + 0.0, + 0.0 + ], + [ + -0.09999999749003845, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999670321011, + 0.0, + 0.0 + ], + [ + -0.09999999665338462, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999587901269, + 0.0, + 0.0 + ], + [ + -0.09999999581673082, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999505481527, + 0.0, + 0.0 + ], + [ + -0.09999999498007706, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999423061788, + 0.0, + 0.0 + ], + [ + -0.09999999414342331, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999340642052, + 0.0, + 0.0 + ], + [ + -0.09999999330676958, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999258222318, + 0.0, + 0.0 + ], + [ + -0.09999999247011587, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999175802586, + 0.0, + 0.0 + ], + [ + -0.09999999163346218, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999093382855, + 0.0, + 0.0 + ], + [ + -0.09999999079680853, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999999010963126, + 0.0, + 0.0 + ], + [ + -0.0999999899601549, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998928543398, + 0.0, + 0.0 + ], + [ + -0.09999998912350128, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998846123674, + 0.0, + 0.0 + ], + [ + -0.0999999882868477, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998763703953, + 0.0, + 0.0 + ], + [ + -0.09999998745019412, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998681284235, + 0.0, + 0.0 + ], + [ + -0.09999998661354056, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998598864518, + 0.0, + 0.0 + ], + [ + -0.09999998577688703, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998516444801, + 0.0, + 0.0 + ], + [ + -0.0999999849402335, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998434025086, + 0.0, + 0.0 + ], + [ + -0.09999998410358002, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998351605374, + 0.0, + 0.0 + ], + [ + -0.09999998326692656, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998269185664, + 0.0, + 0.0 + ], + [ + -0.09999998243027311, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998186765957, + 0.0, + 0.0 + ], + [ + -0.09999998159361968, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0999999810434625, + 0.0, + 0.0 + ], + [ + -0.09999998075696626, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999998021926547, + 0.0, + 0.0 + ], + [ + -0.09999997992031284, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997939506845, + 0.0, + 0.0 + ], + [ + -0.09999997908365944, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997857087146, + 0.0, + 0.0 + ], + [ + -0.09999997824700611, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997774667448, + 0.0, + 0.0 + ], + [ + -0.09999997741035281, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997692247753, + 0.0, + 0.0 + ], + [ + -0.09999997657369951, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997609828061, + 0.0, + 0.0 + ], + [ + -0.09999997573704623, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997527408369, + 0.0, + 0.0 + ], + [ + -0.09999997490039297, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0999999744498868, + 0.0, + 0.0 + ], + [ + -0.09999997406373973, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997362568992, + 0.0, + 0.0 + ], + [ + -0.0999999732270865, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997280149306, + 0.0, + 0.0 + ], + [ + -0.09999997239043328, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997197729622, + 0.0, + 0.0 + ], + [ + -0.0999999715537801, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997115309943, + 0.0, + 0.0 + ], + [ + -0.09999997071712693, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999997032890263, + 0.0, + 0.0 + ], + [ + -0.09999996988047377, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996950470587, + 0.0, + 0.0 + ], + [ + -0.09999996904382066, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0999999686805091, + 0.0, + 0.0 + ], + [ + -0.09999996820716758, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996785631235, + 0.0, + 0.0 + ], + [ + -0.09999996737051453, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996703211564, + 0.0, + 0.0 + ], + [ + -0.09999996653386149, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996620791893, + 0.0, + 0.0 + ], + [ + -0.09999996569720845, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996538372227, + 0.0, + 0.0 + ], + [ + -0.09999996486055543, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996455952563, + 0.0, + 0.0 + ], + [ + -0.09999996402390247, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996373532899, + 0.0, + 0.0 + ], + [ + -0.09999996318724952, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996291113236, + 0.0, + 0.0 + ], + [ + -0.09999996235059656, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996208693578, + 0.0, + 0.0 + ], + [ + -0.09999996151394362, + 0.0, + 0.0 + ] + ], + [ + [ + 0.0999999612627392, + 0.0, + 0.0 + ], + [ + -0.09999996067729072, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999996043854267, + 0.0, + 0.0 + ], + [ + -0.09999995984063785, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999995961434617, + 0.0, + 0.0 + ], + [ + -0.09999995900398499, + 0.0, + 0.0 + ] + ], + [ + [ + 0.09999995879014968, + 0.0, + 0.0 + ], + [ + -0.09999995816733213, + 0.0, + 0.0 + ] + ] + ], + "distance_history": [ + 0.14142135506291026, + 0.141421353888511, + 0.14142135271411177, + 0.14142135153971258, + 0.14142135036531342, + 0.1414213491909143, + 0.14142134801651518, + 0.14142134684211613, + 0.14142134566771708, + 0.14142134449331806, + 0.1414213433189191, + 0.14142134214452015, + 0.1414213409701212, + 0.14142133979572233, + 0.14142133862132347, + 0.14142133744692467, + 0.14142133627252587, + 0.1414213350981271, + 0.14142133392372833, + 0.14142133274932964, + 0.14142133157493095, + 0.14142133040053229, + 0.14142132922613365, + 0.14142132805173502, + 0.14142132687733644, + 0.14142132570293792, + 0.14142132452853942, + 0.14142132335414095, + 0.14142132217974251, + 0.14142132100534408, + 0.1414213198309457, + 0.1414213186565473, + 0.14142131748214895, + 0.14142131630775065, + 0.14142131513335238, + 0.1414213139589541, + 0.1414213127845559, + 0.14142131161015772, + 0.14142131043575956, + 0.14142130926136143, + 0.14142130808696332, + 0.14142130691256524, + 0.14142130573816722, + 0.14142130456376922, + 0.14142130338937123, + 0.14142130221497326, + 0.14142130104057532, + 0.14142129986617746, + 0.1414212986917796, + 0.14142129751738178 + ], + "target": [ + 0.0, + 0.0 + ] +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/multi_step/convergence/phase_space.png b/Things/Continuous_Generic/Output/tests/multi_step/convergence/phase_space.png new file mode 100644 index 0000000..5886289 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/convergence/phase_space.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/convergence/prediction_analysis.png b/Things/Continuous_Generic/Output/tests/multi_step/convergence/prediction_analysis.png new file mode 100644 index 0000000..57f3938 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/convergence/prediction_analysis.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/convergence/state_correlations.png b/Things/Continuous_Generic/Output/tests/multi_step/convergence/state_correlations.png new file mode 100644 index 0000000..1cd2832 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/convergence/state_correlations.png differ diff --git a/Things/Continuous_Generic/Output/tests/multi_step/convergence/time_evolution.png b/Things/Continuous_Generic/Output/tests/multi_step/convergence/time_evolution.png new file mode 100644 index 0000000..23c9861 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/multi_step/convergence/time_evolution.png differ diff --git a/Things/Continuous_Generic/Output/tests/single_step/free_energy/data.json b/Things/Continuous_Generic/Output/tests/single_step/free_energy/data.json new file mode 100644 index 0000000..7df54f9 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/single_step/free_energy/data.json @@ -0,0 +1,25 @@ +{ + "state": [ + [ + 0.09999999587901269, + 0.0, + 0.0 + ], + [ + -0.09999999581673082, + 0.0, + 0.0 + ] + ], + "observation": [ + 0.0, + 0.0 + ], + "free_energy": [ + 0.020000279999999673, + 13.835582850610585, + 13.835582900097055, + 13.835582949583518, + 13.835582999069986 + ] +} \ No newline at end of file diff --git a/Things/Continuous_Generic/Output/tests/single_step/free_energy/energy_diagnostics.png b/Things/Continuous_Generic/Output/tests/single_step/free_energy/energy_diagnostics.png new file mode 100644 index 0000000..8c53214 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/single_step/free_energy/energy_diagnostics.png differ diff --git a/Things/Continuous_Generic/Output/tests/single_step/free_energy/energy_distribution.png b/Things/Continuous_Generic/Output/tests/single_step/free_energy/energy_distribution.png new file mode 100644 index 0000000..a1a03f0 Binary files /dev/null and b/Things/Continuous_Generic/Output/tests/single_step/free_energy/energy_distribution.png differ diff --git a/Things/Continuous_Generic/Output/tests/single_step/taylor_step/data.json b/Things/Continuous_Generic/Output/tests/single_step/taylor_step/data.json new file mode 100644 index 0000000..2c24088 --- /dev/null +++ b/Things/Continuous_Generic/Output/tests/single_step/taylor_step/data.json @@ -0,0 +1,35 @@ +{ + "initial_state": [ + [ + 0.010002075937558768, + 0.004999169595885761, + -0.0010000000000000022 + ], + [ + 0.019997924062441125, + -0.004999169595885761, + 0.0009999999999999979 + ] + ], + "final_state": [ + [ + 0.010002075937558768, + 0.004999169595885761, + -0.0010000000000000022 + ], + [ + 0.019997924062441125, + -0.004999169595885761, + 0.0009999999999999979 + ] + ], + "predicted_position": [ + 0.010000499995, + 0.019999500005 + ], + "predicted_velocity": [ + 0.0049999, + -0.0049999 + ], + "dt": 0.0001 +} \ No newline at end of file diff --git a/Things/Continuous_Generic/__pycache__/conftest.cpython-310-pytest-8.3.2.pyc b/Things/Continuous_Generic/__pycache__/conftest.cpython-310-pytest-8.3.2.pyc index fc523ea..435b1b7 100644 Binary files a/Things/Continuous_Generic/__pycache__/conftest.cpython-310-pytest-8.3.2.pyc and b/Things/Continuous_Generic/__pycache__/conftest.cpython-310-pytest-8.3.2.pyc differ diff --git a/Things/Continuous_Generic/__pycache__/continuous_generic.cpython-310.pyc b/Things/Continuous_Generic/__pycache__/continuous_generic.cpython-310.pyc index 0ba5389..3ea303b 100644 Binary files a/Things/Continuous_Generic/__pycache__/continuous_generic.cpython-310.pyc and b/Things/Continuous_Generic/__pycache__/continuous_generic.cpython-310.pyc differ diff --git a/Things/Continuous_Generic/__pycache__/test_continuous_generic.cpython-310-pytest-8.3.2.pyc b/Things/Continuous_Generic/__pycache__/test_continuous_generic.cpython-310-pytest-8.3.2.pyc index 99025f7..4ea1273 100644 Binary files a/Things/Continuous_Generic/__pycache__/test_continuous_generic.cpython-310-pytest-8.3.2.pyc and b/Things/Continuous_Generic/__pycache__/test_continuous_generic.cpython-310-pytest-8.3.2.pyc differ diff --git a/Things/Continuous_Generic/__pycache__/visualization.cpython-310.pyc b/Things/Continuous_Generic/__pycache__/visualization.cpython-310.pyc index ce55586..d41e470 100644 Binary files a/Things/Continuous_Generic/__pycache__/visualization.cpython-310.pyc and b/Things/Continuous_Generic/__pycache__/visualization.cpython-310.pyc differ diff --git a/src/models/active_inference/dispatcher.py b/src/models/active_inference/dispatcher.py new file mode 100644 index 0000000..101beb8 --- /dev/null +++ b/src/models/active_inference/dispatcher.py @@ -0,0 +1,202 @@ +""" +Active Inference method dispatcher and high-level abstractions. +Provides a clean interface for dispatching active inference operations +to appropriate low-level implementations. +""" + +from enum import Enum +from typing import Dict, List, Optional, Tuple, Union, Any, Callable +import numpy as np +from dataclasses import dataclass +from pathlib import Path + +from .base import ActiveInferenceModel, ModelState +from ..matrices.matrix_ops import MatrixOps, MatrixInitializer + +class InferenceMethod(Enum): + """Supported inference methods.""" + VARIATIONAL = "variational" + SAMPLING = "sampling" + MEAN_FIELD = "mean_field" + +class PolicyType(Enum): + """Supported policy types.""" + DISCRETE = "discrete" + CONTINUOUS = "continuous" + HIERARCHICAL = "hierarchical" + +@dataclass +class InferenceConfig: + """Configuration for inference method dispatch.""" + method: InferenceMethod + policy_type: PolicyType + temporal_horizon: int + learning_rate: float + precision_init: float + use_gpu: bool = False + custom_params: Optional[Dict[str, Any]] = None + +class ActiveInferenceDispatcher: + """ + Dispatcher for Active Inference operations. + Provides high-level interface and handles routing to specific implementations. + """ + + def __init__(self, config: InferenceConfig): + """Initialize dispatcher with configuration.""" + self.config = config + self._setup_implementations() + self._initialize_matrices() + + def _setup_implementations(self): + """Set up mapping of operations to implementations.""" + self._implementations = { + InferenceMethod.VARIATIONAL: { + 'belief_update': self._variational_belief_update, + 'policy_inference': self._variational_policy_inference + }, + InferenceMethod.SAMPLING: { + 'belief_update': self._sampling_belief_update, + 'policy_inference': self._sampling_policy_inference + }, + InferenceMethod.MEAN_FIELD: { + 'belief_update': self._mean_field_belief_update, + 'policy_inference': self._mean_field_policy_inference + } + } + + def _initialize_matrices(self): + """Initialize required matrices based on configuration.""" + self.matrix_ops = MatrixOps() + self.matrix_init = MatrixInitializer() + + def dispatch_belief_update(self, + observation: np.ndarray, + current_state: ModelState, + **kwargs) -> np.ndarray: + """ + Dispatch belief update to appropriate implementation. + + Args: + observation: Current observation + current_state: Current model state + **kwargs: Additional parameters for specific implementations + + Returns: + Updated beliefs + """ + update_fn = self._implementations[self.config.method]['belief_update'] + return update_fn(observation, current_state, **kwargs) + + def dispatch_policy_inference(self, + state: ModelState, + goal_prior: Optional[np.ndarray] = None, + **kwargs) -> np.ndarray: + """ + Dispatch policy inference to appropriate implementation. + + Args: + state: Current model state + goal_prior: Optional prior over goal states + **kwargs: Additional parameters for specific implementations + + Returns: + Inferred policy distributions + """ + inference_fn = self._implementations[self.config.method]['policy_inference'] + return inference_fn(state, goal_prior, **kwargs) + + def _variational_belief_update(self, + observation: np.ndarray, + state: ModelState, + **kwargs) -> np.ndarray: + """Variational implementation of belief updates.""" + # Implementation details for variational belief updates + prediction = np.dot(state.beliefs, kwargs.get('generative_matrix', np.eye(len(state.beliefs)))) + prediction_error = observation - prediction + belief_update = state.precision * prediction_error + return state.beliefs + belief_update + + def _sampling_belief_update(self, + observation: np.ndarray, + state: ModelState, + **kwargs) -> np.ndarray: + """Sampling-based implementation of belief updates.""" + # Implementation for sampling-based updates + raise NotImplementedError("Sampling-based belief updates not yet implemented") + + def _mean_field_belief_update(self, + observation: np.ndarray, + state: ModelState, + **kwargs) -> np.ndarray: + """Mean-field implementation of belief updates.""" + # Implementation for mean-field updates + raise NotImplementedError("Mean-field belief updates not yet implemented") + + def _variational_policy_inference(self, + state: ModelState, + goal_prior: Optional[np.ndarray] = None, + **kwargs) -> np.ndarray: + """Variational implementation of policy inference.""" + # Implementation for variational policy inference + if goal_prior is None: + goal_prior = np.ones(len(state.policies)) / len(state.policies) + + expected_free_energy = self._calculate_expected_free_energy( + state, goal_prior, **kwargs) + return self.matrix_ops.softmax(-expected_free_energy) + + def _sampling_policy_inference(self, + state: ModelState, + goal_prior: Optional[np.ndarray] = None, + **kwargs) -> np.ndarray: + """Sampling-based implementation of policy inference.""" + raise NotImplementedError("Sampling-based policy inference not yet implemented") + + def _mean_field_policy_inference(self, + state: ModelState, + goal_prior: Optional[np.ndarray] = None, + **kwargs) -> np.ndarray: + """Mean-field implementation of policy inference.""" + raise NotImplementedError("Mean-field policy inference not yet implemented") + + def _calculate_expected_free_energy(self, + state: ModelState, + goal_prior: np.ndarray, + **kwargs) -> np.ndarray: + """Calculate expected free energy for policy evaluation.""" + # Basic implementation - can be extended based on specific needs + pragmatic_value = -np.log(goal_prior + 1e-8) # Avoid log(0) + epistemic_value = self._calculate_epistemic_value(state) + return pragmatic_value + epistemic_value + + def _calculate_epistemic_value(self, state: ModelState) -> np.ndarray: + """Calculate epistemic value component of expected free energy.""" + # Simple implementation - can be extended + return -state.prediction_error * np.ones(len(state.policies)) + +class ActiveInferenceFactory: + """Factory for creating Active Inference instances with specific configurations.""" + + @staticmethod + def create(config: InferenceConfig) -> ActiveInferenceDispatcher: + """Create an Active Inference dispatcher with specified configuration.""" + return ActiveInferenceDispatcher(config) + + @staticmethod + def create_from_yaml(config_path: Union[str, Path]) -> ActiveInferenceDispatcher: + """Create an Active Inference dispatcher from YAML configuration.""" + import yaml + with open(config_path, 'r') as f: + config_dict = yaml.safe_load(f) + + config = InferenceConfig( + method=InferenceMethod(config_dict['method']), + policy_type=PolicyType(config_dict['policy_type']), + temporal_horizon=config_dict['temporal_horizon'], + learning_rate=config_dict['learning_rate'], + precision_init=config_dict['precision_init'], + use_gpu=config_dict.get('use_gpu', False), + custom_params=config_dict.get('custom_params', None) + ) + return ActiveInferenceFactory.create(config) \ No newline at end of file diff --git a/tests/test_continuous_generic.py b/tests/test_continuous_generic.py new file mode 100644 index 0000000..f1eca4d --- /dev/null +++ b/tests/test_continuous_generic.py @@ -0,0 +1,276 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.gridspec import GridSpec +import seaborn as sns +from scipy.signal import hilbert +import pytest +from pathlib import Path + +class TestComplexDynamics: + """Test suite for complex dynamical behaviors.""" + + @pytest.fixture(autouse=True) + def setup(self, tmp_path): + """Setup test fixtures.""" + plt.style.use('seaborn') + sns.set_palette("husl") + self.output_dir = tmp_path / "figures" + self.output_dir.mkdir(exist_ok=True) + + # Test parameters + self.dt = 0.01 + self.t_max = 10.0 + self.num_steps = int(self.t_max / self.dt) + self.time = np.linspace(0, self.t_max, self.num_steps) + + # System parameters + self.omega = 2.0 # Natural frequency + self.damping = 0.1 + self.amplitude = 1.0 + self.frequency = 2.5 + + yield + + # Cleanup + plt.close('all') + + def simulate_harmonic_motion(self): + """Simulate harmonic oscillator dynamics.""" + states = np.zeros((self.num_steps, 2)) + states[0] = [1.0, 0.0] # Initial conditions + + for i in range(1, self.num_steps): + # Simple harmonic motion with damping + states[i, 0] = states[i-1, 0] + self.dt * states[i-1, 1] + states[i, 1] = states[i-1, 1] - self.dt * ( + self.omega**2 * states[i-1, 0] + + 2 * self.damping * states[i-1, 1] + ) + + return states + + def test_harmonic_motion(self): + """Test visualization of harmonic motion dynamics.""" + states = self.simulate_harmonic_motion() + free_energy = self.compute_free_energy(states) + + fig = plt.figure(figsize=(15, 10)) + gs = GridSpec(2, 3, figure=fig) + + # Phase space trajectory + ax1 = fig.add_subplot(gs[0, 0]) + ax1.plot(states[:, 0], states[:, 1], 'b-', label='Phase trajectory') + ax1.set_xlabel('Position') + ax1.set_ylabel('Velocity') + ax1.set_title('Phase Space') + ax1.grid(True) + ax1.legend() + + # Time series + ax2 = fig.add_subplot(gs[0, 1:]) + ax2.plot(self.time, states[:, 0], 'b-', label='Position') + ax2.plot(self.time, states[:, 1], 'r--', label='Velocity') + ax2.set_xlabel('Time (s)') + ax2.set_ylabel('State Variables') + ax2.set_title('Time Evolution') + ax2.grid(True) + ax2.legend() + + # Energy plot + ax3 = fig.add_subplot(gs[1, 0]) + kinetic = 0.5 * states[:, 1]**2 + potential = 0.5 * self.omega**2 * states[:, 0]**2 + total = kinetic + potential + ax3.plot(self.time, kinetic, 'g-', label='Kinetic') + ax3.plot(self.time, potential, 'r-', label='Potential') + ax3.plot(self.time, total, 'k--', label='Total') + ax3.set_xlabel('Time (s)') + ax3.set_ylabel('Energy') + ax3.set_title('Energy Components') + ax3.grid(True) + ax3.legend() + + # Free energy evolution + ax4 = fig.add_subplot(gs[1, 1:]) + if len(free_energy) > 0: # Only plot if free energy is computed + ax4.plot(self.time, free_energy, 'b-', label='Free Energy') + ax4.legend() + ax4.set_xlabel('Time (s)') + ax4.set_ylabel('Free Energy') + ax4.set_title('Free Energy Evolution') + ax4.grid(True) + + plt.tight_layout() + plt.savefig(self.output_dir / 'harmonic_motion_analysis.png', dpi=300, bbox_inches='tight') + plt.close() + + # Assertions to verify the simulation + assert np.all(np.isfinite(states)), "States contain invalid values" + assert np.all(np.abs(total - total[0]) < 1e-2), "Energy is not conserved" + + def test_driven_oscillator(self): + """Test visualization of driven oscillator dynamics.""" + states = self.simulate_driven_oscillator() + + fig = plt.figure(figsize=(15, 12)) + gs = GridSpec(3, 2, figure=fig) + + # Phase space with driving force + ax1 = fig.add_subplot(gs[0, 0]) + ax1.plot(states[:, 0], states[:, 1], 'b-', label='Phase trajectory') + ax1.set_xlabel('Position') + ax1.set_ylabel('Velocity') + ax1.set_title('Phase Space') + ax1.grid(True) + ax1.legend() + + # Time series with driving force + ax2 = fig.add_subplot(gs[0, 1]) + driving_force = self.amplitude * np.sin(self.frequency * self.time) + ax2.plot(self.time, states[:, 0], 'b-', label='Position') + ax2.plot(self.time, states[:, 1], 'r--', label='Velocity') + ax2.plot(self.time, driving_force, 'g:', label='Driving Force') + ax2.set_xlabel('Time (s)') + ax2.set_ylabel('State Variables') + ax2.set_title('Time Evolution') + ax2.grid(True) + ax2.legend() + + # Power spectrum + ax3 = fig.add_subplot(gs[1, :]) + frequencies = np.fft.fftfreq(len(states), self.dt) + spectrum = np.abs(np.fft.fft(states[:, 0])) + mask = frequencies > 0 # Only show positive frequencies + ax3.plot(frequencies[mask], spectrum[mask], 'b-', label='Position Spectrum') + ax3.set_xlabel('Frequency (Hz)') + ax3.set_ylabel('Amplitude') + ax3.set_title('Power Spectrum') + ax3.grid(True) + ax3.legend() + + # Phase difference analysis + ax4 = fig.add_subplot(gs[2, 0]) + phase_diff = np.angle(hilbert(states[:, 0])) - np.angle(hilbert(driving_force)) + ax4.plot(self.time, np.unwrap(phase_diff), 'r-', label='Phase Difference') + ax4.set_xlabel('Time (s)') + ax4.set_ylabel('Phase Difference (rad)') + ax4.set_title('Phase Relationship') + ax4.grid(True) + ax4.legend() + + # Response amplitude vs time + ax5 = fig.add_subplot(gs[2, 1]) + envelope = np.abs(hilbert(states[:, 0])) + ax5.plot(self.time, envelope, 'r-', label='Response Amplitude') + ax5.plot(self.time, np.abs(driving_force), 'b--', label='Driving Amplitude') + ax5.set_xlabel('Time (s)') + ax5.set_ylabel('Amplitude') + ax5.set_title('Response Amplitude') + ax5.grid(True) + ax5.legend() + + plt.tight_layout() + plt.savefig(self.output_dir / 'driven_oscillator_analysis.png', dpi=300, bbox_inches='tight') + plt.close() + + # Assertions to verify the simulation + assert np.all(np.isfinite(states)), "States contain invalid values" + assert np.max(np.abs(states[:, 0])) > 0, "No oscillation detected" + + def simulate_driven_oscillator(self): + """Simulate driven oscillator dynamics.""" + states = np.zeros((self.num_steps, 2)) + states[0] = [0.0, 0.0] # Initial conditions + + for i in range(1, self.num_steps): + driving_force = self.amplitude * np.sin(self.frequency * self.time[i]) + states[i, 0] = states[i-1, 0] + self.dt * states[i-1, 1] + states[i, 1] = states[i-1, 1] - self.dt * ( + self.omega**2 * states[i-1, 0] + + 2 * self.damping * states[i-1, 1] - + driving_force + ) + + return states + + def compute_free_energy(self, states): + """Compute free energy for the system.""" + # Placeholder - implement actual free energy computation + return np.zeros_like(self.time) + +class TestGeneralizedCoordinates: + """Test suite for generalized coordinates.""" + + @pytest.fixture(autouse=True) + def setup(self, tmp_path): + """Setup test fixtures.""" + plt.style.use('seaborn') + sns.set_palette("husl") + self.output_dir = tmp_path / "figures" + self.output_dir.mkdir(exist_ok=True) + + yield + + plt.close('all') + + def test_generalized_coordinates_consistency(self): + """Test consistency of generalized coordinates predictions.""" + # ... existing test code ... + + # Plotting + fig, (ax1, ax2, ax3, ax4) = plt.subplots(2, 2, figsize=(12, 10)) + + # Plot position predictions + lines1 = ax1.plot(time_points, positions, 'b-', label='Actual') + ax1.plot(time_points, predicted_positions, 'r--', label='Predicted') + ax1.set_xlabel('Time (s)') + ax1.set_ylabel('Position') + ax1.set_title('Position Prediction') + if lines1: # Only add legend if there are plotted lines + ax1.legend() + ax1.grid(True) + + # Plot velocity predictions + lines2 = ax2.plot(time_points, velocities, 'b-', label='Actual') + ax2.plot(time_points, predicted_velocities, 'r--', label='Predicted') + ax2.set_xlabel('Time (s)') + ax2.set_ylabel('Velocity') + ax2.set_title('Velocity Prediction') + if lines2: # Only add legend if there are plotted lines + ax2.legend() + ax2.grid(True) + + # Plot acceleration predictions + lines3 = ax3.plot(time_points, accelerations, 'b-', label='Actual') + ax3.plot(time_points, predicted_accelerations, 'r--', label='Predicted') + ax3.set_xlabel('Time (s)') + ax3.set_ylabel('Acceleration') + ax3.set_title('Acceleration Prediction') + if lines3: # Only add legend if there are plotted lines + ax3.legend() + ax3.grid(True) + + # Plot prediction errors + lines4 = [] + if len(position_errors) > 0: + lines4.extend(ax4.plot(time_points[1:], position_errors, 'r-', label='Position Error')) + if len(velocity_errors) > 0: + lines4.extend(ax4.plot(time_points[1:], velocity_errors, 'b--', label='Velocity Error')) + if len(acceleration_errors) > 0: + lines4.extend(ax4.plot(time_points[1:], acceleration_errors, 'g:', label='Acceleration Error')) + + ax4.set_xlabel('Time (s)') + ax4.set_ylabel('Prediction Error') + ax4.set_title('Prediction Errors') + if lines4: # Only add legend if there are plotted lines + ax4.legend() + ax4.grid(True) + + plt.tight_layout() + plt.savefig(self.output_dir / 'generalized_coordinates_predictions.png', dpi=300, bbox_inches='tight') + plt.close() + + # Assertions + assert np.all(np.isfinite(positions)), "Invalid position values" + assert np.all(np.isfinite(velocities)), "Invalid velocity values" + assert np.all(np.isfinite(accelerations)), "Invalid acceleration values" \ No newline at end of file