This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- module MatpowerCases | |
- using MAT | |
- | |
- export loadcase,casenames | |
- | |
- """ Return a Dict containing power system data | |
- in MATPOWER's format. | |
- Return this list of cases by running casenames(). | |
- """ | |
- function loadcase(caseName::ASCIIString; describe=true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Requests, Graphs, ProgressMeter | |
function surfer(root,n=100) | |
# Crawling mechanics: hyperlink regex and | |
# filter used for skipping certain links | |
rexp = r"https?://[^\"|<|>|;|'|)| |…]+" | |
# Focus on links that contribute to the graph by skipping | |
# all links that contain the following strings: | |
skip = [".gif";".jpg";".jpeg";".pdf";".css";".js";".asp";".mwc";".ram"; | |
".cgi";"lmscadsi";"cybernet";"w3.org";"google";"yahoo"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
createY(f,t,x [,r,b]) -> Y | |
Create an admittance matrix for AC power flow. | |
All inputs are real. The output matrix is real if no line | |
resistances are provided (DC case), and complex otherwise. | |
* `f`,`t`: vectors encoding all lines (fi,ti) | |
* `x`: per-unit reactance xi for all lines | |
* `r`: per-unit resistance ri for all lines | |
* `b`: per-unit susceptance bi for all lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Calculate injection shift factor matrix. | |
Each row corresponds to a line in the network. | |
Each column corresponds to a node. | |
Credit to Jonathon Martin for derivation. | |
Inputs: | |
* `Y`: full admittance matrix | |
* `lines`: vector of tuples; each tuple encodes a line as (i,j) | |
* `ref`: index of angle reference bus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Naive LU decomposition (no pivoting) from | |
[Bindel's CS6210 class notes](http://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec09.pdf). | |
Beware A[1,1] = 0... | |
""" | |
function mylu(A) | |
m,n = size(A) | |
for j = 1:n-1 | |
A[j+1:n,j] = A[j+1:n,j]/A[j,j] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Given a permutation vector, return the corresponding permutation matrix such that | |
`A[p,:] = P*A`. | |
See [Wikipedia](https://en.wikipedia.org/wiki/Permutation_matrix#Definition). | |
""" | |
function pvec2mat(p) | |
n = length(p) | |
P = zeros(n,n) | |
for i in 1:n | |
P[i,:] = ej(n,p[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
LTC model used by [Baghsorkhi2015](http://deepblue.lib.umich.edu/handle/2027.42/113584) | |
(see section 5.3.2). | |
""" | |
type DBODE | |
"index of bus whose voltage is regulated" | |
bus::Int64 | |
"index of line whose tap is influenced" | |
line::Int64 | |
"voltage setpoint [pu]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def procrustes(shapes): | |
""" | |
Syntax: ashapes, sm = procrustes(shapes) | |
Inputs: shapes is a n x p x d array, where n is the number of | |
shapes, p is the number of points per shape, and d is | |
the dimension of each point (d=2 for xy plane, etc.). | |
Thus, shapes[0,5,:] contains the d coordinates for the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sonic Pi v2.10 | |
use_bpm 130 | |
notes = (ring :b3, :fs3, :g3, :c4) | |
notes_sliced = (ring :b3, :as3, :a3, :as3) | |
define :long do | |
4.times do | |
with_fx :bitcrusher, mix: 0.2 do | |
with_synth :hoover do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Optim | |
import Optim.retract! | |
import Optim.project_tangent! | |
struct SphereSubspaceComplementIntersection <: Manifold | |
U::Matrix | |
proj::Matrix | |
end | |
function SphereSubspaceComplementIntersection(U) |
OlderNewer