Import and Export Network Configuration
Importing a Matpower Network Configuration
This example demonstrates how to import a network configuration from a Matpower case file and run a power flow analysis on it. The casefile is located in the data
directory of the package. The run_acpflow
function is used to run the power flow analysis.
Example
using Sparlectra
using Logging
file = "case3.m"
tol = 1e-8
ite = 10
verbose = 0 # 0: no output, 1: iteration norm, 2: + Y-Bus, 3: + Jacobian, 4: + Power Flow
# Call acpflow function with input parameters and measure execution time
run_acpflow(max_ite= ite,tol = tol, casefile=file)
!!! Note Please note that providing support for individualized network data issues is beyond the scope of this project, as it is not maintained by an organization. Users are encouraged to take initiative in resolving such issues independently and sharing their results with the community.
Sparlectra.casefileparser
— Methodcasefileparser(filename)
Parses a MATPOWER case file and returns the case name, base power, and bus, generator, and branch data.
Arguments
filename
: The name of the file to parse.
Returns
case_name
: The name of the case.baseMVA
: The base power in MVA.mpc_bus
: The bus data matrix.mpc_gen
: The generator data matrix.mpc_branch
: The branch data matrix.
Example
case_name, baseMVA, mpc_bus, mpc_gen, mpc_branch = casefileparser("case9.m")
Sparlectra.createNetFromMatPowerFile
— FunctionCreates a network from a MatPower case file.
Arguments
filename
: Path to the MatPower case file.log::Bool = false
: Whether to log information (default: false).
Returns
A Net object representing the network.
Sparlectra.writeMatpowerCasefile
— MethodwriteMatpowerCasefile(net::Net, pathfilename::String)
Write Matpower case files.
Arguments
net::Net
: Network object.pathfilename::String
: Path and filename to write the Matpower case file.
Example
net = Net(...)
writeMatpowerCasefile(net, "casefile.m")
Sparlectra.run_acpflow
— MethodFunction to perform AC power flow analysis.
Parameters:
- max_ite: Int, the maximum number of iterations for the power flow algorithm (default: 10).
- tol: Float64, tolerance for convergence criterion (default: 1e-6).
- casefile: String, the name of the case file to load.
- path: Union{Nothing,String}, the path to the case file (default: nothing).
- verbose: Int, verbosity level for output (default: 0).
- printResultToFile: Bool, flag to print results to a file (default: false).
- printResultAnyCase: Bool, flag to print results even if the power flow fails (default: false).
Returns:
- Net, the network object.
Sparlectra.run_net_acpflow
— MethodFunction to perform AC power flow analysis.
Parameters:
- net: Net, the network object.
- max_ite: Int, the maximum number of iterations for the power flow algorithm (default: 10).
- tol: Float64, tolerance for convergence criterion (default: 1e-6).
- verbose: Int, verbosity level for output (default: 0).
- printResultToFile: Bool, flag to print results to a file (default: false).
- printResultAnyCase: Bool, flag to print results even if the power flow fails (default: false).