solution.py
"""
Ackrep solution file for backstepping-based control of an unstable heat equation
"""
from problem import ProblemSpecification
from feedback import AnalyticBacksteppingController, ApproximatedBacksteppingController
import matplotlib.pyplot as plt
import matplotlib
import pyinduct as pi
from ackrep_core.system_model_management import save_plot_in_dir
import os
class SolutionData:
pass
def solve(problem_spec: ProblemSpecification):
# get values from spec
spatial_domain = problem_spec.spatial_domain
orig_params = problem_spec.orig_params
fem_sys = problem_spec.fem_sys
modal_sys = problem_spec.modal_sys
n_modal = problem_spec.n_modal_sim
# target system parameters (controller parameters)
# Note: Backstepping is not able to alter a1 or a2!
a0_t = 0
tar_params = [problem_spec.a2, problem_spec.a1, a0_t, None, None]
# define analytic backstepping controller
analytic_cont = AnalyticBacksteppingController(spatial_domain, orig_params, fem_sys)
# define approximated backstepping controllers
approx_cont_mod = ApproximatedBacksteppingController(orig_params, tar_params, n_modal, spatial_domain, modal_sys)
approx_cont_fem = ApproximatedBacksteppingController(orig_params, tar_params, n_modal, spatial_domain, fem_sys)
sol_data = SolutionData()
sol_data.u = analytic_cont
sys = problem_spec.fem_sys.get_system(sol_data.u)
ics = problem_spec.fem_sys.get_initial_state(problem_spec.initial_profile, sol_data.u)
t_sim, q_sim = pi.simulate_state_space(sys, ics, problem_spec.temp_domain)
x_sim = problem_spec.fem_sys.get_results(q_sim, sol_data.u, t_sim, problem_spec.spatial_domain, "FEM Simulation")
sol_data.x = x_sim
# visualization
# avoid qt since there are problems when running headless in docker container
matplotlib.use("Agg")
pi.surface_plot(x_sim) # , title="Surface plots")
# pi.surface_plot(x_sim, title="Surface plots")
save_plot_in_dir()
return sol_data
Entity passed last: 2023-07-03 13:14:44
with ackrep_data commit: {'author': 'JuliusFiedler', 'branch': 'develop', 'date': '2023-07-03 13:12:35', 'message': 'fix typos and folder names', 'sha': '180d385f485e4aa0d3df6c7a716fa9d1270dc4f3'}
with ackrep_core commit: {'author': 'JuliusFiedler', 'branch': 'develop', 'date': '2023-07-03 09:44:41', 'message': 'black', 'sha': '2bde08d26afc7227546533ecd58f249d24063462'}
in environment: default_conda_environment:0.1.12
Checkout CI Build
Checking <ProblemSolution (pk: 17, key: HOZEE)> "(PyInduct backstepping example, 10s)"
12:18:25 - ackrep - INFO - ... Creating exec-script ...
12:18:25 - ackrep - INFO - execscript-path: /code/ackrep/ackrep_data/execscript.py
12:18:25 - ackrep - INFO - ... running exec-script /code/ackrep/ackrep_data/execscript.py ...
12:18:26 - ackrep - ERROR -
The command `python /code/ackrep/ackrep_data/execscript.py` exited with returncode 1.
stdout:
stderr: Traceback (most recent call last):
File "/code/ackrep/ackrep_data/execscript.py", line 41, in <module>
import problem as ps
File "/code/ackrep/ackrep_data/problem_specifications/pyinduct_backstepping_example/problem.py", line 5, in <module>
import pyinduct as pi
File "/opt/conda/lib/python3.8/site-packages/pyinduct/__init__.py", line 17, in <module>
from .eigenfunctions import *
File "/opt/conda/lib/python3.8/site-packages/pyinduct/eigenfunctions.py", line 24, in <module>
from .visualization import visualize_roots
File "/opt/conda/lib/python3.8/site-packages/pyinduct/visualization.py", line 19, in <module>
import pyqtgraph.opengl as gl
File "/opt/conda/lib/python3.8/site-packages/pyqtgraph/opengl/__init__.py", line 1, in <module>
from . import shaders
File "/opt/conda/lib/python3.8/site-packages/pyqtgraph/opengl/shaders.py", line 1, in <module>
from OpenGL.GL import * # noqa
File "/opt/conda/lib/python3.8/site-packages/OpenGL/GL/__init__.py", line 4, in <module>
from OpenGL.GL.VERSION.GL_1_1 import *
File "/opt/conda/lib/python3.8/site-packages/OpenGL/GL/VERSION/GL_1_1.py", line 14, in <module>
from OpenGL.raw.GL.VERSION.GL_1_1 import *
File "/opt/conda/lib/python3.8/site-packages/OpenGL/raw/GL/VERSION/GL_1_1.py", line 7, in <module>
from OpenGL.raw.GL import _errors
File "/opt/conda/lib/python3.8/site-packages/OpenGL/raw/GL/_errors.py", line 4, in <module>
_error_checker = _ErrorChecker( _p, _p.GL.glGetError )
AttributeError: 'NoneType' object has no attribute 'glGetError'
Fail.