### Install PYPOWER using setuptools Source: https://github.com/rwl/pypower/blob/master/doc/install.md Use this command to install PYPOWER if you have setuptools installed. ```bash $ easy_install PYPOWER ``` -------------------------------- ### Configure, Compile, and Install IPOPT Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Configure IPOPT with a specified installation prefix, compile it, and install the libraries and headers. The default prefix is ./lib/ and ./include/coin. ```bash $ ./configure --prefix=/usr/local $ make $ sudo make install ``` -------------------------------- ### List Command Options Source: https://github.com/rwl/pypower/blob/master/README.rst After installation, 'pf' and 'opf' commands are available. Use -h to list options. ```bash venv/bin/pf -h ``` ```bash venv/bin/opf -h ``` -------------------------------- ### Compile and Install PyIPOPT Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Compile the PyIPOPT extension module and install it to the specified Python site-packages directory. ```bash $ make $ make install ``` -------------------------------- ### Install PYPOWER from tarball Source: https://github.com/rwl/pypower/blob/master/doc/install.md Download, unpack, and install PYPOWER from a tarball. This method is useful if setuptools is not available or preferred. ```bash $ tar zxf PYPOWER-4.0.tar.gz $ python setup.py install ``` -------------------------------- ### Install PYPOWER using Pip Source: https://github.com/rwl/pypower/blob/master/README.rst Install PYPOWER using pip within your virtual environment. ```bash venv/bin/python -m pip install PYPOWER ``` -------------------------------- ### Create Virtual Environment Source: https://github.com/rwl/pypower/blob/master/README.rst Recommended way to install PYPOWER is within a virtual environment. Use any supported Python version. ```bash python3.8 -m venv venv # Or any supported Python version ``` -------------------------------- ### Configure ld.so.conf.d for IPOPT Libraries Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Create a configuration file in /etc/ld.so.conf.d/ to inform the system linker about the locations of the installed IPOPT and MUMPS libraries. ```bash $ sudo nano -w /etc/ld.so.conf.d/ipopt.conf ``` -------------------------------- ### Install LP Solve Python Extension Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Compile and install the Python extension for lp_solve. Ensure the Python source code is in the same directory as the lp_solve source. ```bash $ cd ../extra/Python/ $ sudo python setup.py install ``` -------------------------------- ### Install Dependencies Source: https://github.com/rwl/pypower/blob/master/README.rst PYPOWER requires NumPy, SciPy, and PyRLU. Install them using pip and a requirements file. ```bash venv/bin/python -m pip install -r requirements.txt ``` -------------------------------- ### Install PYPOWER with sudo (UNIX) Source: https://github.com/rwl/pypower/blob/master/doc/install.md On UNIX systems, use sudo if installation requires root privileges for script directories. ```bash $ sudo python setup.py install ``` -------------------------------- ### Install LP Solve Library Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Copy the compiled lp_solve shared library files to a system library path. ```bash $ cp bin/ux32/* /usr/loca/lib/ ``` -------------------------------- ### Get Help for runpf Function Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Access the built-in help documentation for the runpf function to understand its parameters and usage. ```ipython help runpf ``` -------------------------------- ### Run PYPOWER Tests Source: https://github.com/rwl/pypower/blob/master/README.rst Test PYPOWER locally using tox, similar to the Travis CI setup. Specify desired Python versions. ```bash venv/bin/python -m tox -e py27,py38 # Or any supported Python version ``` -------------------------------- ### Clone PYPOWER development repository Source: https://github.com/rwl/pypower/blob/master/doc/install.md Clone the PYPOWER Git repository from GitHub to get the latest development version. ```bash $ git clone http://github.com/rwl/PYPOWER.git ``` -------------------------------- ### Loading a Case, Running Power Flow, and Printing Results Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Demonstrates the basic workflow of loading a power system case, configuring power flow options, executing the power flow calculation, and displaying the results. ```APIDOC ## Loading a Case, Running Power Flow, and Printing Results ### Description This example shows how to load a standard test case (case9), set power flow options using `ppoption` (specifying the fast-decoupled method with `PF_ALG=2`), run the power flow calculation with `runpf`, and then print the results using `printpf`. ### Usage ```python from pypower.api import case9, ppoption, runpf, printpf # Load the 9 bus test case ppc = case9() # Set power flow options (PF_ALG=2 for fast-decoupled method) ppopt = ppoption(PF_ALG=2) # Run the power flow calculation r = runpf(ppc, ppopt) # Print the results printpf(r) ``` ### Functions Used - `case9()`: Loads the 9 bus test case. - `ppoption(**kwargs)`: Sets options for the power flow calculation. - `runpf(ppc, ppopt)`: Solves the AC power flow. - `printpf(r)`: Prints the results of the power flow calculation. ``` -------------------------------- ### Print Help Message for 'pf' Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Use the '-h' or '--help' flag to display all available options and usage information for the 'pf' command. ```bash $ pf -h ``` -------------------------------- ### Load Case, Run Power Flow, and Print Results Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Load the 9 bus test case, solve an AC power flow using the fast-decoupled method, and print the results. Ensure ppoption is configured for the desired algorithm. ```ipython ppc = case9() ``` ```ipython ppopt = ppoption(PF_ALG=2) ``` ```ipython r = runpf(ppc, ppopt) ``` ```ipython printpf(r) ``` -------------------------------- ### Run Power Flow with Case File Path Source: https://github.com/rwl/pypower/blob/master/README.rst Specify the path to a PYPOWER case data file for power flow analysis. ```bash venv/bin/pf /path/to/case14.py ``` -------------------------------- ### Download and Extract IPOPT Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Download the IPOPT source code and extract it. Ensure the version is newer than 3.9.1. ```bash $ wget http://www.coin-or.org/download/source/Ipopt/Ipopt-3.9.3.tgz $ tar xvf Ipopt-3.9.3.tgz $ cd Ipopt-3.9.3/ ``` -------------------------------- ### Build LP Solve Library Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Compile the lp_solve library from source. This is required before compiling the Python extension. ```bash $ cd lp_solve_5.5/lpsolve55 $ sh ./ccc ``` -------------------------------- ### Run Power Flow with a Case File Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Execute a power flow calculation by providing the direct path to a PYPOWER case data file. This allows using custom or external case files. ```bash $ pf /path/to/case14.py ``` -------------------------------- ### Solve OPF and Save Case Source: https://github.com/rwl/pypower/blob/master/README.rst Solve an Optimal Power Flow problem for a given case and save the results to a new file. ```bash venv/bin/opf -c case24_ieee_rts --solvedcase=rtsout.py ``` -------------------------------- ### Specify IPOPT and MUMPS Library Paths Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Add the paths to the IPOPT and MUMPS libraries to the newly created ld.so.conf.d file. This ensures the linker can find them. ```text /usr/local/lib/coin /usr/local/lib/coin/ThirdParty ``` -------------------------------- ### Run Optimal Power Flow and Save Results Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Solve an optimal power flow problem for a specified test case and save the solved case data to a new file. This is useful for analyzing OPF solutions. ```bash $ opf -c case24_ieee_rts --solvedcase=rtsout.py ``` -------------------------------- ### Configure PyIPOPT Makefile Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Modify the PyIPOPT Makefile to correctly point to your IPOPT, MUMPS, Python, and NumPy include and library paths. Adjust CC, CFLAGS, DFLAGS, LDFLAGS, PY_DIR, IPOPT_INCLUDE, IPOPT_LIB, MUMPS_INCLUDE, MUMPS_LIB, PYTHON_INCLUDE, and NUMPY_INCLUDE variables as needed. ```makefile CC = gcc CFLAGS = -O3 -fpic -shared #-g DFLAGS = -fpic -shared LDFLAGS = -lipopt -lm -llapack -lblas -lcoinmumps PY_DIR = /usr/local/lib/python2.6/dist-packages IPOPT_INCLUDE = /usr/local/include/coin IPOPT_LIB = /usr/local/lib/coin MUMPS_INCLUDE=/usr/local/include/coin/ThirdParty MUMPS_LIB = /usr/local/lib/coin/ThirdParty PYTHON_INCLUDE = /usr/include/python2.6 NUMPY_INCLUDE = /usr/include/numpy pyipopt: src/callback.c src/pyipopt.c $(CC) -o pyipopt.so -L$(IPOPT_LIB) -I$(IPOPT_INCLUDE) -L$(MUMPS_LIB) -I$(MUMPS_INCLUDE) -I$(PYTHON_INCLUDE) -I$(NUMPY_INCLUDE) $(CFLAGS) $(LDFLAGS) src/pyipopt.c src/callback.c install: pyipopt cp ./pyipopt.so $(PY_DIR) clean: rm pyipopt.so ``` -------------------------------- ### Import PYPOWER API Functions Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Import the essential functions from the pypower.api package for power flow analysis. ```ipython from pypower.api import case9, ppoption, runpf, printpf ``` -------------------------------- ### Run Power Flow on a Test Case Source: https://github.com/rwl/pypower/blob/master/doc/usage.md Execute a power flow calculation using a named PYPOWER test case. Ensure the test case is available in the PYPOWER environment. ```bash $ pf -c case14 ``` -------------------------------- ### Run Power Flow on Test Case Source: https://github.com/rwl/pypower/blob/master/README.rst Execute a power flow analysis on a specified test case, like the IEEE 14 bus system. ```bash venv/bin/pf -c case14 ``` -------------------------------- ### PYPOWER 'pf' Command Usage Source: https://github.com/rwl/pypower/blob/master/doc/usage.md The 'pf' command runs a power flow calculation. It accepts an optional 'casedata' file and various options to control the power flow algorithm, termination tolerance, iteration limits, and output formatting. ```bash Usage: pf [options] [casedata] Runs a power flow. If 'casedata' is provided it specifies the name of the input data file containing the case data. Options: --version show program's version number and exit -h, --help show this help message and exit -t, --test run tests -c TESTCASE, --testcase=TESTCASE built-in test case (choose from: 'case30_userfcns', 'case118', 'case9', 'case30Q', 'case30pwl', 'case6ww', 'case57', 'case39', 'case14', 'case9Q', 'case30', 'case300', 'case4gs', 'case24_ieee_rts') -o FNAME, --outfile=FNAME pretty printed output will be appended to a file with the name specified. Defaults to stdout. -s SOLVEDCASE, --solvedcase=SOLVEDCASE the solved case will be written to a case file with the specified name in PYPOWER format. If solvedcase ends with '.mat' the case is saves as a MAT-file otherwise it saves it as a Python file. Power Flow Options: --pf_alg=PF_ALG power flow algorithm: 1 - Newton's method, 2 - Fast- Decoupled (XB version), 3 - Fast-Decoupled (BX version), 4 - Gauss Seidel [default: 1] --pf_tol=PF_TOL termination tolerance on per unit P & Q mismatch [default: 1e-08] --pf_max_it=PF_MAX_IT maximum number of iterations for Newton's method [default: 10] --pf_max_it_fd=PF_MAX_IT_FD maximum number of iterations for fast decoupled method [default: 30] --pf_max_it_gs=PF_MAX_IT_GS maximum number of iterations for Gauss-Seidel method [default: 1000] --enforce_q_lims=ENFORCE_Q_LIMS enforce gen reactive power limits, at expense of |V| [default: False] --pf_dc=PF_DC use DC power flow formulation, for power flow and OPF: False - use AC formulation & corresponding algorithm opts, True - use DC formulation, ignore AC algorithm options [default: False] Output Options: --verbose=VERBOSE amount of progress info printed: 0 - print no progress info, 1 - print a little progress info, 2 - print a lot of progress info, 3 - print all progress info [default: 1] --out_all=OUT_ALL controls printing of results: -1 - individual flags control what prints, 0 - don't print anything (overrides individual flags, except OUT_RAW), 1 - print everything (overrides individual flags, except OUT_RAW) [default: -1] --out_sys_sum=OUT_SYS_SUM print system summary [default: True] --out_area_sum=OUT_AREA_SUM print area summaries [default: False] --out_bus=OUT_BUS print bus detail [default: True] --out_branch=OUT_BRANCH print branch detail [default: True] --out_gen=OUT_GEN print generator detail (OUT_BUS also includes gen info) [default: False] --out_all_lim=OUT_ALL_LIM control constraint info output: -1 - individual flags control what constraint info prints, 0 - no constraint info (overrides individual flags), 1 - binding constraint info (overrides individual flags), 2 - all constraint info (overrides individual flags) [default: -1] --out_v_lim=OUT_V_LIM control output of voltage limit info: 0 - don't print, 1 - print binding constraints only, 2 - print all constraints (same options for OUT_LINE_LIM, OUT_PG_LIM, OUT_QG_LIM) [default: 1] --out_line_lim=OUT_LINE_LIM control output of line limit info [default: 1] --out_pg_lim=OUT_PG_LIM control output of gen P limit info [default: 1] --out_qg_lim=OUT_QG_LIM control output of gen Q limit info [default: 1] --out_raw=OUT_RAW print raw data [default: False] --return_raw_der=RETURN_RAW_DER return constraint and derivative info in results['raw'] (in keys g, dg, df, d2f)) [default: 0] ``` -------------------------------- ### Checkout PyIPOPT Source Code Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Obtain the latest PyIPOPT source code using Subversion. Ensure you are in the directory above the desired checkout location. ```bash $ cd .. $ svn checkout https://pyipopt.googlecode.com/svn/trunk/ pyipopt $ cd pyipopt/ ``` -------------------------------- ### Download and Patch MUMPS for IPOPT Source: https://github.com/rwl/pypower/blob/master/doc/solvers.md Navigate to the MUMPS directory within the IPOPT source and use the provided script to download and patch MUMPS, a required linear solver for IPOPT. ```bash $ cd ThirdParty/Mumps $ ./get.Mumps $ cd ../.. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.