Exemplo n.º 1
0
void Inductance::time_step()
{
	if (!b_status) return;
	
	double i = p_cbranch[0]->i;
	double v_eq_new = 0.0, r_eq_new = 0.0;
	
	if ( m_method == Inductance::m_euler )
	{
		r_eq_new = m_inductance / m_delta;
		v_eq_new = -i * r_eq_new;
	}
	else if ( m_method == Inductance::m_trap ) {
		// TODO Implement + test trapezoidal method
		r_eq_new = 2.0 * m_inductance / m_delta;
	}
	
	if ( scaled_inductance != r_eq_new )
	{
		A_d( 0, 0 ) -= r_eq_new - scaled_inductance;
	}
	
	if ( v_eq_new != v_eq_old )
	{
		b_v( 0 ) += v_eq_new - v_eq_old;
	}
	
	scaled_inductance = r_eq_new;
	v_eq_old = v_eq_new;
}
Exemplo n.º 2
0
void Inductance::time_step()
{
    if (!b_status) return;

    double i = p_cbranch[0]->current();
    double v_eq_new = 0.0, r_eq_new = 0.0;

    if(m_method == Inductance::m_euler) {
        r_eq_new = m_inductance / m_delta;
        v_eq_new = -i * r_eq_new;
    } else if ( m_method == Inductance::m_trap ) {
        // TODO Implement + test trapezoidal method
        r_eq_new = 2.0 * m_inductance / m_delta;
// We need to update v_eq_new here but I don't know if this is the right code.
        v_eq_new = -i * r_eq_new;
    }

    if(scaled_inductance != r_eq_new) {
        A_d(0, 0) -= r_eq_new - scaled_inductance;
    }

    b_v(0) = v_eq_new;

    scaled_inductance = r_eq_new;
}
Exemplo n.º 3
0
void VoltagePoint::add_initial_dc() {
	if (!b_status) return;

	A_b(0, 0) = -1;
	A_c(0, 0) = 1;

	b_v(0) = m_voltage;
}
Exemplo n.º 4
0
/* FIXME:
	Often times, you want to use one of these to set a voltage in a circuit but not pass
current. This creates a singular matrix. Depending on how Matrix is set up, it might either cause the
circuit to glitch out or will create a virtual one ohm resistor either into a component that shouldn't be conducting and draw/source that current from wherever it is avaliable. =P

VoltageSignal also exhibits this problem.
*/
void VoltageSource::add_initial_dc() {
	if (!b_status)
		return;

	A_b(0, 0) = -1;
	A_c(0, 0) = -1;
	A_b(1, 0) = 1;
	A_c(0, 1) = 1;

	b_v(0) = m_v;
}
Exemplo n.º 5
0
R125Class::R125Class()
{
	double n[] = {0.0, 5.280760, -8.676580, 0.7501127, 0.7590023, 0.01451899, 4.777189, -3.330988, 3.775673, -2.290919, 0.8888268, -0.6234864, -0.04127263, -0.08455389, -0.1308752, 0.008344962, -1.532005, -0.05883649, 0.02296658};
	double t[] = {0, 0.669, 1.05, 2.75, 0.956, 1.00, 2.00, 2.75, 2.38, 3.37, 3.47, 2.63, 3.45, 0.72, 4.23, 0.20, 4.5, 29.0, 24.0};
	double d[] = {0, 1, 1, 1, 2, 4, 1, 1, 2, 2, 3, 4, 5, 1, 5, 1, 2, 3, 5};
	double l[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 2, 3, 3};
	double m[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.7, 7.0, 6.0};

	//Critical parameters
	crit.rho = 4.779*120.0214; //[kg/m^3]
	crit.p = PressureUnit(3617.7, UNIT_KPA); //[kPa]
	crit.T = 339.173; //[K]
	crit.v = 1/crit.rho; 

	// Other fluid parameters
	params.molemass = 120.0214;
	params.Ttriple = 172.52;
	params.accentricfactor = 0.3052;
	params.R_u = 8.314472;
	params.ptriple = 2.914;

	// Limits of EOS
	limits.Tmin = params.Ttriple;
	limits.Tmax = 500.0;
	limits.pmax = 100000.0;
	limits.rhomax = 1000000.0*params.molemass;

	phirlist.push_back(new phir_Lemmon2005( n,d,t,l,m,1,18,19));

	const double a1 = 37.2674, a2 = 8.88404, a3 = -49.8651;
	phi0list.push_back(new phi0_lead(a1,a2));
	phi0list.push_back(new phi0_logtau(-1));
	phi0list.push_back(new phi0_power(a3,-0.1));

	double a[] = {0,0,0,0, 2.303, 5.086, 7.3};
	double b[] = {0,0,0,0, 0.92578, 2.22895, 5.03283};

	std::vector<double> a_v(a,a+sizeof(a)/sizeof(double));
	std::vector<double> b_v(b,b+sizeof(b)/sizeof(double));

	phi0list.push_back(new phi0_Planck_Einstein(a_v,b_v,4,6));

	EOSReference.assign("Lemmon-JPCRD-2005");
	TransportReference.assign("Viscosity: Huber IECR 2006\n\n Conductivity: Perkins JCED 2006");
	name.assign("R125");
	REFPROPname.assign("R125");

	BibTeXKeys.EOS = "Lemmon-JPCRD-2005";
	BibTeXKeys.VISCOSITY = "Huber-IECR-2006";
	BibTeXKeys.CONDUCTIVITY = "Perkins-JCED-2006";
	BibTeXKeys.ECS_LENNARD_JONES = "Huber-IECR-2006";
	BibTeXKeys.SURFACE_TENSION = "Mulero-JPCRD-2012";
}
Exemplo n.º 6
0
TYPED_TEST_P(atomic_test, increment)
{
	using limits = std::numeric_limits<TypeParam>;
	const TypeParam first = limits::max() / 2 - 1;

	atomic::atomic<TypeParam> a_v(first);
	EXPECT_EQ(first, static_cast<TypeParam>(a_v));
	atomic::atomic<TypeParam> b_v(static_cast<TypeParam>(++a_v));
	EXPECT_EQ(first + 1, static_cast<TypeParam>(a_v));
	EXPECT_EQ(first + 1, static_cast<TypeParam>(b_v));
	atomic::atomic<TypeParam> c_v(static_cast<TypeParam>(a_v++));
	EXPECT_EQ(first + 1, static_cast<TypeParam>(c_v));
	EXPECT_EQ(first + 2, static_cast<TypeParam>(a_v));
}
Exemplo n.º 7
0
void VoltageSignal::time_step()
{
	if (!b_status) return;
	b_v( 0 ) =  m_voltage*advance(m_delta);
}
Exemplo n.º 8
0
R22Class::R22Class()
{
	static const double n[]={0,
	0.0695645445236, //[1]
	25.2275419999, //[2]
	-202.351148311, //[3]
	350.063090302, //[4]
	-223.134648863, //[5]
	48.8345904592, //[6]
	0.0108874958556, //[7]
	0.590315073614, //[8]
	-0.689043767432, //[9]
	0.284224445844, //[10]
	0.125436457897, //[11]
	-0.0113338666416, //[12]
	-0.063138895917, //[13]
	0.00974021015232, //[14]
	-0.000408406844722, //[15]
	0.00074194877357, //[16]
	0.000315912525922, //[17]
	0.00000876009723338, //[18]
	-0.000110343340301, //[19]
	-0.0000705323356879, //[20]
	0.23585073151, //[21]
	-0.192640494729, //[22]
	0.00375218008557, //[23]
	-0.0000448926036678, //[24]
	0.0198120520635, //[25]
	-0.0356958425255, //[26]
	0.0319594161562, //[27]
	0.00000260284291078, //[28]
	-0.00897629021967, //[29]
	0.0345482791645, //[30]
	-0.00411831711251, //[31]
	0.00567428536529, //[32]
	-0.00563368989908, //[33]
	0.00191384919423, //[34]
	-0.00178930036389 //[35]
	};

	static const double d[]={0,
	1, //[1]
	1, //[2]
	1, //[3]
	1, //[4]
	1, //[5]
	1, //[6]
	1, //[7]
	2, //[8]
	2, //[9]
	2, //[10]
	3, //[11]
	3, //[12]
	4, //[13]
	5, //[14]
	6, //[15]
	7, //[16]
	7, //[17]
	7, //[18]
	8, //[19]
	8, //[20]
	2, //[21]
	2, //[22]
	2, //[23]
	2, //[24]
	3, //[25]
	4, //[26]
	4, //[27]
	4, //[28]
	4, //[29]
	6, //[30]
	6, //[31]
	6, //[32]
	8, //[33]
	8, //[34]
	8, //[35]
	};

	static const double t[]={0,
		-1, //[1]
		1.75, //[2]
		2.25, //[3]
		2.5, //[4]
		2.75, //[5]
		3, //[6]
		5.5, //[7]
		1.5, //[8]
		1.75, //[9]
		3.5, //[10]
		1, //[11]
		4.5, //[12]
		1.5, //[13]
		0.5, //[14]
		4.5, //[15]
		1, //[16]
		4, //[17]
		5, //[18]
		-0.5, //[19]
		3.5, //[20]
		5, //[21]
		7, //[22]
		12, //[23]
		15, //[24]
		3.5, //[25]
		3.5, //[26]
		8, //[27]
		15, //[28]
		25, //[29]
		3, //[30]
		9, //[31]
		19, //[32]
		2, //[33]
		7, //[34]
		13 //[35]
	};

	static const double l[]={0,
		0, //[1]
		0, //[2]
		0, //[3]
		0, //[4]
		0, //[5]
		0, //[6]
		0, //[7]
		0, //[8]
		0, //[9]
		0, //[10]
		0, //[11]
		0, //[12]
		0, //[13]
		0, //[14]
		0, //[15]
		0, //[16]
		0, //[17]
		0, //[18]
		0, //[19]
		0, //[20]
		2, //[21]
		2, //[22]
		2, //[23]
		2, //[24]
		3, //[25]
		2, //[26]
		2, //[27]
		2, //[28]
		4, //[29]
		2, //[30]
		2, //[31]
		4, //[32]
		2, //[33]
		2, //[34]
		4 //[35]
	};

	static const double B[]={0,
	4352.3095, //[1]
	1935.1591, //[2]
	1887.67936, //[3]
	1694.88284, //[4]
	1605.67848, //[5]
	1162.53424, //[6]
	857.51288, //[7]
	605.72638, //[8]
	530.90982, //[9]
	5.26140446e-3, //[10] 
	1.20662553e-4 //[11]
	};

	std::vector<double> B_v(B,B+sizeof(B)/sizeof(double));
	std::vector<double> b_v(10,1.0);

	phirlist.push_back(new phir_power(n,d,t,l,1,35,36));

	double T0=273.15, 
		   p0=1.0, 
		   R_=8.31451/86.549,
		   rho0=p0/(R_*T0),
		   m,
		   c,
		   R_u=8.31451,
		   Tc=369.295,
		   H0 = 35874.80, /// kJ/kmol
		   S0 = 205.2925, /// kJ/kmol/K
		   tau0=Tc/T0, 
		   delta0=rho0/523.84216696;
	
	// log(delta)+c+m*tau
	
	/// c is the constant term
	c=-S0/R_u-1+log(tau0/delta0);/*<< from the leading term*/

	/// m multiplies the tau term in the leading term (slope)
	m=H0/(R_u*Tc); /*<< from the leading term */

	for (unsigned int i=1; i<=9; i++){B_v[i]/=Tc;}

	phi_BC * phi0_lead_ = new phi0_lead(c,m);
	phi_BC * phi0_logtau_ = new phi0_logtau(-1.0);
	phi_BC * phi0_cp0_constant_ = new phi0_cp0_constant(B[10]+4,Tc,T0);/// checked - good
	phi_BC * phi0_cp0_poly_ = new phi0_cp0_poly(B[11],1,Tc,T0);/// checked - good
	//phi_BC * phi0_cp0_exponential_ = new phi0_cp0_exponential(b_v,B_v,Tc,T0,1,9);/// checked - good

	phi0list.push_back(phi0_lead_);
	phi0list.push_back(phi0_logtau_);
	phi0list.push_back(phi0_cp0_constant_);
	phi0list.push_back(phi0_cp0_poly_);
	//phi0list.push_back(phi0_cp0_exponential_);
	phi0list.push_back(new phi0_Planck_Einstein(b_v,B_v,1,9));
	
	
	// Other fluid parameters
	params.molemass = 86.468;
	params.Ttriple = 115.73;
	params.ptriple = 0.00037947;
	params.accentricfactor = 0.22082;
	params.R_u = 8.314510;

	// Critical parameters
	crit.rho = 6.05822*params.molemass;
	crit.p = PressureUnit(4990, UNIT_KPA);
	crit.T = 369.295;
	crit.v = 1.0/crit.rho;

	// Limits of EOS
	limits.Tmin = params.Ttriple;
	limits.Tmax = 550.0;
	limits.pmax = 60000.0;
	limits.rhomax = 19.91*params.molemass;
	
	EOSReference.assign("Kamei, A., and S. W. Beyerlein, and R. T Jacobsen "
						"\"Application of Nonlinear Regression in the "
						"Development of a Wide Range Formulation "
						"for HCFC-22\""
						"International Journal of Thermophysics, Vol 16, No. 5, 1995 ");
	TransportReference.assign("Using ECS");
	name.assign("R22");

	BibTeXKeys.EOS = "Kamei-IJT-1995";
	BibTeXKeys.ECS_LENNARD_JONES = "McLinden-IJR-2000";
	BibTeXKeys.ECS_FITS = "McLinden-IJR-2000";
	BibTeXKeys.SURFACE_TENSION = "Mulero-JPCRD-2012";

}
Exemplo n.º 9
0
R744Class::R744Class()
{

	static double alpha[40],beta[43],GAMMA[40],epsilon[40],a[43],b[43],A[43],B[43],C[43],D[43],a0[9],theta0[9];
	static double n[]={0,    
	 0.388568232032E+00,
	 0.293854759427E+01,
	-0.558671885350E+01,
	-0.767531995925E+00,
	 0.317290055804E+00,
	 0.548033158978E+00,
	 0.122794112203E+00,
	 
	 0.216589615432E+01,
	 0.158417351097E+01,
	-0.231327054055E+00,
	 0.581169164314E-01,
	-0.553691372054E-00,
	 0.489466159094E-00,
	-0.242757398435E-01,
	 0.624947905017E-01,
	-0.121758602252E+00,
	-0.370556852701E+00,
	-0.167758797004E-01,
	-0.119607366380E+00,
	-0.456193625088E-01,
	 0.356127892703E-01, 
	-0.744277271321E-02,
	-0.173957049024E-02,
	-0.218101212895E-01,
	 0.243321665592E-01,
	-0.374401334235E-01,
	 0.143387157569E-00,
	-0.134919690833E-00,
	-0.231512250535E-01,
	 0.123631254929E-01,
	 0.210583219729E-02,
	-0.339585190264E-03,
	 0.559936517716E-02,
	-0.303351180556E-03,

	-0.213654886883E+03,
	 0.266415691493E+05,
	-0.240272122046E+05,
	-0.283416034240E+03,
	 0.212472844002E+03,
	 
	-0.666422765408E+00,
	 0.726086323499E+00,
	 0.550686686128E-01};

	static double d[]={0,
	1,
	1,
	1,
	1,
	2,
	2,
	3,
	1,
	2,
	4,
	5,
	5,
	5,
	6,
	6,
	6,
	1,
	1,
	4,
	4,
	4,
	7,
	8,
	2,
	3,
	3,
	5,
	5,
	6,
	7,
	8,
	10,
	4,
	8,
	2,
	2,
	2,
	3,
	3};

	static double t[]={0.00,
	0.00,
	0.75,
	1.00,
	2.00,
	0.75,
	2.00,
	0.75,
	1.50,
	1.50,
	2.50,
	0.00,
	1.50,
	2.00,
	0.00,
	1.00,
	2.00,
	3.00,
	6.00,
	3.00,
	6.00,
	8.00,
	6.00,
	0.00,
	7.00,
	12.00,
	16.00,
	22.00,
	24.00,
	16.00,
	24.00,
	8.00,
	2.00,
	28.00,
	14.00,
	1.00,
	0.00,
	1.00,
	3.00,
	3.00};

	static double c[]={0,0,0,0,0,0,0,0,
	1,
	1,
	1,
	1,
	1,
	1,
	1,
	1,
	1,
	2,
	2,
	2,
	2,
	2,
	2,
	2,
	3,
	3,
	3,
	4,
	4,
	4,
	4,
	4,
	4,
	5,
	6};

	alpha[35]=25.0;
	alpha[36]=25.0;
	alpha[37]=25.0;
	alpha[38]=15.0;
	alpha[39]=20.0;

	beta[35]=325.0;
	beta[36]=300.0;
	beta[37]=300.0;
	beta[38]=275.0;
	beta[39]=275.0;

	GAMMA[35]=1.16;
	GAMMA[36]=1.19;
	GAMMA[37]=1.19;
	GAMMA[38]=1.25;
	GAMMA[39]=1.22;

	epsilon[35]=1.00;
	epsilon[36]=1.00;
	epsilon[37]=1.00;
	epsilon[38]=1.00;
	epsilon[39]=1.00;

	a[40]=3.5;
	a[41]=3.5;
	a[42]=3.0;

	b[40]=0.875;
	b[41]=0.925;
	b[42]=0.875;

	beta[40]=0.300;
	beta[41]=0.300;
	beta[42]=0.300;

	A[40]=0.700;
	A[41]=0.700;
	A[42]=0.700;

	B[40]=0.3;
	B[41]=0.3;
	B[42]=1.0;

	C[40]=10.0;
	C[41]=10.0;
	C[42]=12.5;

	D[40]=275.0;
	D[41]=275.0;
	D[42]=275.0;

	//Constants for ideal gas expression
	a0[1]=8.37304456;
	a0[2]=-3.70454304;
	a0[3]=2.500000;
	a0[4]=1.99427042;
	a0[5]=0.62105248;
	a0[6]=0.41195293;
	a0[7]=1.04028922;
	a0[8]=0.08327678;

	theta0[4]=3.15163;
	theta0[5]=6.11190;
	theta0[6]=6.77708;
	theta0[7]=11.32384;
	theta0[8]=27.08792;

	std::vector<double> a_v(a,a+sizeof(a)/sizeof(double));
	std::vector<double> b_v(b,b+sizeof(b)/sizeof(double));
	std::vector<double> A_v(A,A+sizeof(A)/sizeof(double));
	std::vector<double> B_v(B,B+sizeof(B)/sizeof(double));
	std::vector<double> C_v(C,C+sizeof(C)/sizeof(double));
	std::vector<double> D_v(D,D+sizeof(D)/sizeof(double));

	phirlist.push_back(new phir_power(n,d,t,c,1,34,35));
	phirlist.push_back(new phir_gaussian(n,d,t,alpha,epsilon,beta,GAMMA,35,39,40));
	phirlist.push_back(new phir_critical(n,d,t,a,b,beta,A,B,C,D,40,42,43));

	std::vector<double> a0_v(a0,a0+sizeof(a0)/sizeof(double));
	std::vector<double> theta0_v(theta0,theta0+sizeof(theta0)/sizeof(double));
	
	phi0list.push_back(new phi0_lead(a0[1],a0[2]));
	phi0list.push_back(new phi0_logtau(a0[3]));
	phi0list.push_back(new phi0_Planck_Einstein(a0,theta0,4,8,9));

	// Critical parameters
	crit.rho = 44.0098*10.6249063;
	crit.p = PressureUnit(7377.3, UNIT_KPA);
	crit.T = 304.1282;
	crit.v = 1.0/crit.rho;

	// Other fluid parameters
	params.molemass = 44.0098;
	params.Ttriple = 216.592;
	params.ptriple = 517.996380545;
	params.R_u = 8.31451;
	params.accentricfactor = 0.22394;

	// Limit parameters
	limits.Tmin = 216.592;
	limits.Tmax = 2000.0;
	limits.pmax = 800000.0;
	limits.rhomax = 37.24 * params.molemass;
	
	EOSReference.assign("\"A New Equation of State for Carbon Dioxide Covering the Fluid Region from the "
						"Triple Point Temperature to 1100 K at Pressures up to 800 MPa\", "
						"R. Span and W. Wagner, J. Phys. Chem. Ref. Data, v. 25, 1996");
		
	TransportReference.assign("\"The Transport Properties of Carbon Dioxide\","
							  " V. Vesovic and W.A. Wakeham and G.A. Olchowy and "
							  "J.V. Sengers and J.T.R. Watson and J. Millat"
							  "J. Phys. Chem. Ref. Data, v. 19, 1990");

	name.assign("CarbonDioxide");
	aliases.push_back("R744");
	aliases.push_back("co2");
	aliases.push_back("CO2");
	aliases.push_back("carbondioxide");
	REFPROPname.assign("CO2");

	// Adjust to the IIR reference state (h=200 kJ/kg, s = 1 kJ/kg for sat. liq at 0C)
    params.HSReferenceState = "IIR";

	BibTeXKeys.EOS = "Span-JPCRD-1996";
	BibTeXKeys.SURFACE_TENSION = "Mulero-JPCRD-2012";
	BibTeXKeys.VISCOSITY = "Vesovic-JPCRD-1990";
	BibTeXKeys.CONDUCTIVITY = "Vesovic-JPCRD-1990";
}