控制模块.statespace.pzmap出现故障

2024-09-29 06:28:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我用control.StateSpace计算系统的零点和极点。在下面的例子中,我想使用control.pzmap来显示结果,但最后一个不起作用。我可以打印sys,看起来还可以,但不能作为control.pzmap的参数

有人能帮我吗

import numpy as np 
import control
from OMPython import ModelicaSystem
import matplotlib.pyplot as plt
from help_fkt import delete_OM_files
#from numpy import pi as pi

L=0.1
R=80
C=3.3e-6


A=  [[0,1/C], 
    [-1/L, -R/L]]
B=[[0],[1/L]]

C=[[1,0],[0,1],[-1,0]]

D= [[0],[0],[1]]


print(A)
print(B)
print(C)
print(D)
fig=plt.figure(1, figsize=(10,6)); fig.clf()
plt.show()

sys=control.StateSpace(A,B,C,D)     #calculation of poles and zeros of the given system
print(sys)

a=sys.pole()
print(a)

control.pzmap(sys)                  #should make a diagram of poles and zeros, but doesn't work

plt.grid()

这就是错误:

File "C:\anaconda3\envs\modsim\lib\site-packages\control\statesp.py", line 575, in zero from slycot import ab08nd

ModuleNotFoundError: No module named 'slycot'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\johan\OneDrive\Desktop\Studium\SimulationundModellbildung\Lösungen\LSG_Carlos\A7.py", line 44, in control.pzmap(sys)

File "C:\anaconda3\envs\modsim\lib\site-packages\control\pzmap.py", line 91, in pzmap zeros = sys.zero()

File "C:\anaconda3\envs\modsim\lib\site-packages\control\statesp.py", line 587, in zero raise NotImplementedError("StateSpace.zero only supports "

NotImplementedError:StateSpace.zero仅支持输入数与输出数相同的系统

尝试安装slycot时出错:

(base) C:\Users\johan>pip install slycot Collecting slycot Using cached slycot-0.4.0.0.tar.gz (1.5 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Requirement already satisfied: numpy in c:\anaconda3\lib\site-packages (from slycot) (1.18.1) Building wheels for collected packages: slycot Building wheel for slycot (PEP 517) ... error ERROR: Command errored out with exit status 1: command: 'c:\anaconda3\python.exe' 'c:\anaconda3\lib\site-packages\pip_vendor\pep517_in_process.py' build_wheel 'C:\Users\johan\AppData\Local\Temp\tmpsxxs_crf' cwd: C:\Users\johan\AppData\Local\Temp\pip-install-r2r2i4rs\slycot Complete output (56 lines): Not searching for unused variables given on the command line. -- The C compiler identification is unknown CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE): The CMAKE_C_COMPILER: cl is not a full path and was not found in the PATH. To use the NMake generator with Visual C++, cmake must be run from a shell that can use the compiler cl from the command line. This environment is unable to invoke the cl compiler. To fix this problem, run cmake from the Visual Studio Command Prompt (vcvarsall.bat). Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "C:/Users/johan/AppData/Local/Temp/pip-install-r2r2i4rs/slycot/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log". See also "C:/Users/johan/AppData/Local/Temp/pip-install-r2r2i4rs/slycot/_cmake_test_compile/build/CMakeFiles/CMakeError.log". FC ('-DCMAKE_Fortran_COMPILER=', 'c:/anaconda3/Library/bin/flang.exe') F2PY ('-DF2PY_EXECUTABLE=', 'c:/anaconda3/Scripts/f2py.exe') NUMPY_INCLUDE ('-DNumPy_INCLUDE_DIR=', 'c:/anaconda3/Include') ['-DSLYCOT_VERSION:STRING=0.4.0', '-DGIT_REVISION:STRING=ac0944b363a6cfcc0c3d5128cdd484d74173aa3b', '-DISRELEASE:STRING=True', '-DFULL_VERSION=0.4.0.gitac0944b', '-GNMake Makefiles', '-DCMAKE_Fortran_COMPILER=c:/anaconda3/Library/bin/flang.exe', '-DF2PY_EXECUTABLE=c:/anaconda3/Scripts/f2py.exe', '-DNumPy_INCLUDE_DIR=c:/anaconda3/Include', '-DCMAKE_Fortran_SIMULATE_VERSION=5.0.0', '-DCMAKE_Fortran_COMPILER_ID=Flang', '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON'] -------------------------------------------------------------------------------- -- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator -------------------------------- --------------------------- ---------------------- ----------------- ------------ ------- -- -- ------- ------------ ----------------- ---------------------- --------------------------- -------------------------------- -- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator - failure -------------------------------------------------------------------------------- ******************************************************************************** scikit-build could not get a working generator for your system. Aborting build. Building windows wheels for Python 3.7 requires Microsoft Visual Studio 2017. Get it with "Visual Studio 2017": https://visualstudio.microsoft.com/vs/ ******************************************************************************** ---------------------------------------- ERROR: Failed building wheel for slycot Failed to build slycot ERROR: Could not build wheels for slycot which use PEP 517 and cannot be installed directly WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available. You should consider upgrading via the 'c:\anaconda3\python.exe -m pip install --upgrade pip' command.


Tags: pipthetoinfromimportbuildfor
1条回答
网友
1楼 · 发布于 2024-09-29 06:28:11

好的,我已经安装了anaconda environment(只为您;))来查明问题所在。这似乎不仅仅是你的机器,使用你使用的软件包有点困难,然后是琐碎的

看来你有两个问题

第一个问题是,您使用的包之一依赖于slycot。但是slycot需要在后台进行一些编译工作才能安装自己。在电脑上编译文件需要在电脑上安装编译器。此包的首选编译器是Visual Studio 2017。如果仔细检查错误消息,它会要求您下载并安装它from this page

第二个问题是我不熟悉的。它抱怨输入空间必须与输出空间大小相同

NotImplementedError: StateSpace.zero only supports systems with the same number of inputs as outputs.

但话说回来,这可能是第一个问题造成的

那么,让我们先安装VS2017,看看这是否解决了问题。如果没有,我们将看看是否有任何变化,并从那里继续

相关问题 更多 >