1+ # -*- coding: utf-8 -*-
2+ """
3+ Abstract base law that new Random Vibration Environment control laws can inherit
4+ from.
5+
6+ Rattlesnake Vibration Control Software
7+ Copyright (C) 2021 National Technology & Engineering Solutions of Sandia, LLC
8+ (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S.
9+ Government retains certain rights in this software.
10+
11+ This program is free software: you can redistribute it and/or modify
12+ it under the terms of the GNU General Public License as published by
13+ the Free Software Foundation, either version 3 of the License, or
14+ (at your option) any later version.
15+
16+ This program is distributed in the hope that it will be useful,
17+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+ GNU General Public License for more details.
20+
21+ You should have received a copy of the GNU General Public License
22+ along with this program. If not, see <https://www.gnu.org/licenses/>.
23+ """
24+
25+ from abc import ABC ,abstractmethod
26+ import numpy as np
27+
28+ class AbstractControlClass (ABC ):
29+ @abstractmethod
30+ def __init__ (self ,specification : np .ndarray , # The specification to control to
31+ extra_control_parameters : str , # Extra parameters specified by the controller
32+ transfer_function : np .ndarray = None , # Transfer Functions
33+ buzz_cpsd : np .ndarray = None , # Buzz test in case cross terms are to be computed
34+ last_response_cpsd : np .ndarray = None , # Last Response for Error Correction
35+ last_output_cpsd : np .ndarray = None , # Last output for Drive-based control
36+ ):
37+ """
38+ Initializes the control law
39+
40+ Note that to facilitate the updating of the control law while the test
41+ is running, the init function will take all control data. If control
42+ is not running, these will be Nones.
43+
44+ Parameters
45+ ----------
46+ specification : np.ndarray
47+ A complex 3d numpy ndarray with dimensions frequency lines x control
48+ channels x control channels representing the specification defined
49+ by a CPSD matrix
50+ extra_control_parameters : str
51+ A string containing any extra parameters that might need to be
52+ passed to the control law. This should be parsed by the __init__
53+ function.
54+ transfer_function : np.ndarray, optional
55+ A complex 3d numpy ndarray with dimensions frequency lines x control
56+ channels x excitation sources representing the FRF matrix measured
57+ by the system identification process between drive voltages and
58+ control response. Will only be passed if the control is switched
59+ mid-run. The default is None.
60+ buzz_cpsd : np.ndarray, optional
61+ A complex 3d numpy ndarray with dimensions frequency lines x control
62+ channels x control channels representing the CPSD matrix measured
63+ by the system identification process. Will only be passed if the
64+ control is switched mid-run. The default is None.
65+ last_response_cpsd : np.ndarray, optional
66+ A complex 3d numpy ndarray with dimensions frequency lines x control
67+ channels x control channels representing the last CPSD matrix of
68+ control channel responses. Will only be passed if the
69+ control is switched mid-run. The default is None.
70+ last_output_cpsd : np.ndarray, optional
71+ A complex 3d numpy ndarray with dimensions frequency lines x drive
72+ channels x drive channels representing the last CPSD matrix of
73+ drive outputs. Will only be passed if the
74+ control is switched mid-run. The default is None.
75+ """
76+ pass
77+
78+ @abstractmethod
79+ def system_id_update (self ,transfer_function : np .ndarray , # The transfer function from the system identification
80+ buzz_cpsd : np .ndarray # The CPSD from the system identification
81+ ):
82+ """
83+ Updates the control law with the data from the system identification
84+
85+ Parameters
86+ ----------
87+ transfer_function : np.ndarray
88+ A complex 3d numpy ndarray with dimensions frequency lines x control
89+ channels x excitation sources representing the FRF matrix measured
90+ by the system identification process between drive voltages and
91+ control response
92+ buzz_cpsd : np.ndarray
93+ A complex 3d numpy ndarray with dimensions frequency lines x control
94+ channels x control channels representing the CPSD matrix measured
95+ by the system identification process
96+
97+ """
98+ pass
99+
100+ @abstractmethod
101+ def control (self ,transfer_function : np .ndarray , # The last update of the transfer function
102+ last_response_cpsd : np .ndarray = None , # Last Response for Error Correction
103+ last_output_cpsd : np .ndarray = None # Last output for Drive-based control
104+ ) -> np .ndarray :
105+ """
106+ Perform the control operations
107+
108+ Parameters
109+ ----------
110+ transfer_function : np.ndarray
111+ A complex 3d numpy ndarray with dimensions frequency lines x control
112+ channels x excitation sources representing the FRF matrix measured
113+ by the system identification process between drive voltages and
114+ control response
115+ last_response_cpsd : np.ndarray
116+ A complex 3d numpy ndarray with dimensions frequency lines x control
117+ channels x control channels representing the last CPSD matrix of
118+ control channel responses. If no previous data exists (first time
119+ through control) it will be None. The default is None.
120+ last_output_cpsd : np.ndarray
121+ A complex 3d numpy ndarray with dimensions frequency lines x drive
122+ channels x drive channels representing the last CPSD matrix of
123+ drive outputs. If no previous data exists (first time
124+ through control) it will be None. The default is None.
125+
126+ Returns
127+ -------
128+ next_output_cpsd : np.ndarray
129+ A complex 3d numpy ndarray with dimensions frequency lines x drive
130+ channels x drive channels representing the new CPSD matrix of
131+ drive outputs that should be played to the shakers.
132+ """
133+ pass
0 commit comments