From ffb2693d79e3535401407558d276d346be279c18 Mon Sep 17 00:00:00 2001 From: James Tocknell Date: Sat, 13 Aug 2022 18:32:03 +1000 Subject: [PATCH] Add compute_jacobian --- src/disc_solver/analyse/compute_jacobian.py | 10 ++++++++++ tests/test_run.py | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/disc_solver/analyse/compute_jacobian.py b/src/disc_solver/analyse/compute_jacobian.py index b9b270db..997b9826 100644 --- a/src/disc_solver/analyse/compute_jacobian.py +++ b/src/disc_solver/analyse/compute_jacobian.py @@ -14,6 +14,7 @@ from ..float_handling import float_type from ..solve.solution import ode_system +from ..utils import get_solutions from .utils import ( single_solution_plotter, common_plotting_options, analyse_main_wrapper, get_common_plot_args, analysis_func_wrapper, plot_output_wrapper, @@ -336,3 +337,12 @@ def plot_jacobian_eigenvectors( ) ax.legend() return fig + + +@analysis_func_wrapper +def compute_jacobian_from_file( + soln_file, *, soln_range=None, eps, θ_scale=float_type(1), **kwargs +): + + soln = get_solutions(soln_file, soln_range) + return compute_jacobian_from_solution(soln, eps=eps, θ_scale=θ_scale) diff --git a/tests/test_run.py b/tests/test_run.py index 39e5d39e..931fc2d5 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -9,6 +9,7 @@ from disc_solver.analyse.component_plot import plot as component_plot from disc_solver.analyse.compute_jacobian import ( jacobian_eigenvalues_plot, jacobian_eigenvectors_plot, + compute_jacobian_from_file, ) from disc_solver.analyse.conserve_plot import conserve_main from disc_solver.analyse.derivs_plot import derivs_plot @@ -536,6 +537,9 @@ def test_jacobian_eigenvectors_file(self, solution_not_approx, plot_file): solution_not_approx, plot_filename=plot_file, eps=1e-10 ) + def test_compute_jacobian_from_solution(self, solution): + compute_jacobian_from_file(solution, eps=1e-10) + def test_taylor_space(mpl_interactive): taylor_space_main()