Commit 4ffebb38 authored by Jim Nutaro's avatar Jim Nutaro
Browse files

Minor performance improvement for solver. Added transformers back into the model.

parent 3d985cad
......@@ -55,7 +55,7 @@ void ElectricalData::configureGenerator(genr_t& genr_data, double mvar_base, dou
// Try to get close to an appropriate set of initial conditions
genr_data.Ef0 = 1.0;
genr_data.w0 = 1.0;
genr_data.Pm0 = sqrt(genr_data.genr_mw*genr_data.genr_mw+genr_data.genr_mvar*genr_data.genr_mvar);
genr_data.Pm0 = genr_data.genr_mw;
}
Complex ElectricalData::getAdmittance(int node)
......
......@@ -20,7 +20,7 @@ const char* const phases[3] = { "a", "b", "c"};
set<string> voltageAmplitudeEstimators;
// Default rate of change for a transformer tap
const double TfRate = 1E-3;
const double TfRate = 1E-1;
// Default initial values for voltages and currents
const double v0 = 0.0;
const double i0 = 0.0;
......@@ -183,7 +183,7 @@ string createGenerator(string busName, ElectricalData::genr_t data, double cap)
string Pref = "pref_"+busName;
string powerDraw;
// Small internal impedance to damp oscillations
static const double resistance = 1E-3;
static const double resistance = 1E-1;
// Set the inductance to its critically damped value
const double inductance = (resistance*resistance*cap/4.0);
for (auto phase: phases)
......@@ -292,16 +292,16 @@ string createBus(
else
result += "+"+current(line_name(line),phase);
i++;
// if (line.tside == bus.ID)
// result += "*"+transformerModulus(busName,phase,line);
if (line.tside == bus.ID)
result += "*"+transformerModulus(busName,phase,line);
}
// Sum of outgoing line currents
for (auto line: data.getLines())
{
if (line.from != bus.ID) continue;
result += string("-")+current(line_name(line),phase);
// if (line.tside == bus.ID)
// result += "/"+transformerModulus(busName,phase,line);
if (line.tside == bus.ID)
result += "/"+transformerModulus(busName,phase,line);
}
// Load current contributions
if (R > 0.0)
......@@ -368,7 +368,7 @@ string createLine(ElectricalData::line_t& line)
// Append the transformer modulus to the appropriate side of the line
// and add the tap control equations. Tap changes to maintain the attached
// bus voltage
/* if (line.tside == line.to)
if (line.tside == line.to)
{
string estimate;
string amp = sineAmplitudeMeasurement(bus_name(line.to),phase,"",estimate);
......@@ -389,7 +389,7 @@ string createLine(ElectricalData::line_t& line)
stateVars.insert(state_var_init_t(varName,1.0));
result += string("der(")+varName+")="+number(TfRate)+"*(1.0-"+estimate+");\n";
va += "/"+transformerModulus(bus_name(line.tside),phase,line);
} */
}
stateVars.insert(state_var_init_t(i,i0));
result += string("der(")+i+string(")=(")+va+"-"+vb;
if (R > 0.0)
......
#include "poly.h"
#include <cfloat>
#include <cmath>
void poly::init(double dx)
{
this->dx[0] = this->dx[1] = dx;
}
void poly::append(double dx)
{
this->dx[1] = this->dx[0];
this->dx[0] = dx;
}
double poly::extrapolate(double h)
{
return 0.5*(3.0*dx[0]-dx[1])*h;
}
double poly::time_until(double q)
{
double ddx = (3.0*dx[0]-dx[1])*0.5;
double dt = (ddx != 0.0) ? q/fabs(ddx) : DBL_MAX;
return dt;
}
#ifndef _poly_h_
#define _poly_h_
class poly
{
public:
// Assign first estimate of derivative
void init(double dx);
// Append a new data value h units of time following the previous one
void append(double dx);
// Time to change by q
double time_until(double q);
// Change over given interval
double extrapolate(double h);
private:
// Two derivative approximations
double dx[2];
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment