double my_microturbineImpl::microturbine_sync(double CircuitA_V_Out_re, double CircuitA_V_Out_im, double CircuitB_V_Out_re, double CircuitB_V_Out_im, double CircuitC_V_Out_re, double CircuitC_V_Out_im, double LineA_V_Out_re, double LineA_V_Out_im, double LineB_V_Out_re, double LineB_V_Out_im, double LineC_V_Out_re, double LineC_V_Out_im)
{
  //gather V_Out for each phase
	//gather I_Out for each phase
	//gather VA_Out for each phase
	//gather Q_Out
	//gather S_Out
	//gather Pf_Out

	phaseA_V_Out.Re() = CircuitA_V_Out_re;
	phaseB_V_Out.Re() = CircuitB_V_Out_re;
	phaseC_V_Out.Re()= CircuitC_V_Out_re;

	phaseA_V_Out.Im() = CircuitA_V_Out_im;
	phaseB_V_Out.Im() = CircuitB_V_Out_im;
	phaseC_V_Out.Im()= CircuitC_V_Out_im;

	phaseA_I_Out.Re() = LineA_V_Out_re;
	phaseB_I_Out.Re() = LineB_V_Out_re;
	phaseC_I_Out.Re()= LineC_V_Out_re;

       phaseA_I_Out.Im() = LineA_V_Out_im;
       	phaseB_I_Out.Im() = LineB_V_Out_im;
       	phaseC_I_Out.Im()= LineC_V_Out_im;



	power_A_Out = (~phaseA_I_Out) * phaseA_V_Out;
	power_B_Out = (~phaseB_I_Out) * phaseB_V_Out;
	power_C_Out = (~phaseC_I_Out) * phaseC_V_Out;
printf("%f %f",phaseA_I_Out.Re(),phaseA_V_Out.Im());


	VA_Out = power_A_Out + power_B_Out + power_C_Out;

	E_A_Internal = determine_source_voltage(phaseA_V_Out, Rinternal, Rload);
	E_B_Internal = determine_source_voltage(phaseB_V_Out, Rinternal, Rload);
	E_C_Internal = determine_source_voltage(phaseC_V_Out, Rinternal, Rload);





	frequency = determine_frequency(VA_Out);



	double loss = calculate_loss(frequency);
	efficiency = 1 - loss;
	Heat_Out = determine_heat(VA_Out, loss);
	Fuel_Used = Heat_Out + VA_Out.Mag();



return VA_Out.Re();

}
Example #2
0
/* Sync is called when the clock needs to advance on the bottom-up pass */
TIMESTAMP microturbine::sync(TIMESTAMP t0, TIMESTAMP t1) 
{
	//gather V_Out for each phase
	//gather I_Out for each phase
	//gather VA_Out for each phase
	//gather Q_Out
	//gather S_Out
	//gather Pf_Out

	phaseA_V_Out = pCircuit_V_A[0];
	phaseB_V_Out = pCircuit_V_B[0];
	phaseC_V_Out = pCircuit_V_C[0];

	phaseA_I_Out = pLine_I_A[0];
	phaseB_I_Out = pLine_I_B[0];
	phaseC_I_Out = pLine_I_C[0];

	gl_verbose("microturbine sync: phaseA_V_Out from parent is: (%f , %f)", phaseA_V_Out.Re(), phaseA_V_Out.Im());
	gl_verbose("microturbine sync: phaseB_V_Out from parent is: (%f , %f)", phaseB_V_Out.Re(), phaseB_V_Out.Im());
	gl_verbose("microturbine sync: phaseC_V_Out from parent is: (%f , %f)", phaseC_V_Out.Re(), phaseC_V_Out.Im());

	gl_verbose("microturbine sync: phaseA_I_Out from parent is: (%f , %f)", phaseA_I_Out.Re(), phaseA_I_Out.Im());
	gl_verbose("microturbine sync: phaseB_I_Out from parent is: (%f , %f)", phaseB_I_Out.Re(), phaseB_I_Out.Im());
	gl_verbose("microturbine sync: phaseC_I_Out from parent is: (%f , %f)", phaseC_I_Out.Re(), phaseC_I_Out.Im());

	power_A_Out = (~phaseA_I_Out) * phaseA_V_Out;
	power_B_Out = (~phaseB_I_Out) * phaseB_V_Out;
	power_C_Out = (~phaseC_I_Out) * phaseC_V_Out;


	gl_verbose("microturbine sync: power_A_Out from parent is: (%f , %f)", power_A_Out.Re(), power_A_Out.Im());
	gl_verbose("microturbine sync: power_B_Out from parent is: (%f , %f)", power_B_Out.Re(), power_B_Out.Im());
	gl_verbose("microturbine sync: power_C_Out from parent is: (%f , %f)", power_C_Out.Re(), power_C_Out.Im());


	VA_Out = power_A_Out + power_B_Out + power_C_Out;

	E_A_Internal = determine_source_voltage(phaseA_V_Out, Rinternal, Rload);
	E_B_Internal = determine_source_voltage(phaseB_V_Out, Rinternal, Rload);
	E_C_Internal = determine_source_voltage(phaseC_V_Out, Rinternal, Rload);


	
	gl_verbose("microturbine sync: E_A_Internal calc is: (%f , %f)", E_A_Internal.Re(), E_A_Internal.Im());
	gl_verbose("microturbine sync: E_B_Internal calc is: (%f , %f)", E_B_Internal.Re(), E_B_Internal.Im());
	gl_verbose("microturbine sync: E_C_Internal calc is: (%f , %f)", E_C_Internal.Re(), E_C_Internal.Im());


	frequency = determine_frequency(VA_Out);

	gl_verbose("microturbine sync: determined frequency is: %f", frequency);

	if(frequency > Max_Frequency){
		throw ("the frequency asked for from the microturbine is too high!");
	}
	if(frequency < Min_Frequency){
		throw ("the frequency asked for from the microturbine is too low!");
	}


	double loss = calculate_loss(frequency);
	efficiency = 1 - loss;
	Heat_Out = determine_heat(VA_Out, loss);
	Fuel_Used = Heat_Out + VA_Out.Mag();
	
	gl_verbose("microturbine sync: about to exit");

return TS_NEVER;
}