TIMESTAMP triplex_node::presync(TIMESTAMP t0)
{
	//Call the functionalized version
	BOTH_triplex_node_presync_fxn();

	return node::presync(t0);
}
//////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION OF DELTA MODE
//////////////////////////////////////////////////////////////////////////
//Module-level call
SIMULATIONMODE triplex_node::inter_deltaupdate_triplex_node(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val,bool interupdate_pos)
{
	//unsigned char pass_mod;
	OBJECT *hdr = OBJECTHDR(this);

	if (interupdate_pos == false)	//Before powerflow call
	{
		//Call triplex-specific call
		BOTH_triplex_node_presync_fxn();

		//Call node presync-equivalent items
		NR_node_presync_fxn();

		//Call sync-equivalent of triplex portion first
		BOTH_triplex_node_sync_fxn();

		//Call node sync-equivalent items (solver occurs at end of sync)
		NR_node_sync_fxn(hdr);

		return SM_DELTA;	//Just return something other than SM_ERROR for this call
	}
	else	//After the call
	{
		//No triplex-specific postsync for node

		//Perform node postsync-like updates on the values
		BOTH_node_postsync_fxn(hdr);

		//No control required at this time - powerflow defers to the whims of other modules
		//Code below implements predictor/corrector-type logic, even though it effectively does nothing
		return SM_EVENT;

		////Do deltamode-related logic
		//if (bustype==SWING)	//We're the SWING bus, control our destiny (which is really controlled elsewhere)
		//{
		//	//See what we're on
		//	pass_mod = iteration_count_val - ((iteration_count_val >> 1) << 1);

		//	//Check pass
		//	if (pass_mod==0)	//Predictor pass
		//	{
		//		return SM_DELTA_ITER;	//Reiterate - to get us to corrector pass
		//	}
		//	else	//Corrector pass
		//	{
		//		//As of right now, we're always ready to leave
		//		//Other objects will dictate if we stay (powerflow is indifferent)
		//		return SM_EVENT;
		//	}//End corrector pass
		//}//End SWING bus handling
		//else	//Normal bus
		//{
		//	return SM_EVENT;	//Normal nodes want event mode all the time here - SWING bus will
		//						//control the reiteration process for pred/corr steps
		//}
	}
}
//////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION OF DELTA MODE
//////////////////////////////////////////////////////////////////////////
//Module-level call
SIMULATIONMODE triplex_load::inter_deltaupdate_triplex_load(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val,bool interupdate_pos)
{
	//unsigned char pass_mod;
	OBJECT *hdr = OBJECTHDR(this);
	bool fault_mode;

	if (interupdate_pos == false)	//Before powerflow call
	{
		//Triplex_load presync items
			if ((solver_method!=SM_FBS) && (SubNode==PARENT))	//Need to do something slightly different with GS and parented node
			{
				shunt[0] = shunt[1] = shunt[2] = 0.0;
				power[0] = power[1] = power[2] = 0.0;
				current[0] = current[1] = current[2] = 0.0;
			}

		//Call triplex-specific call
		BOTH_triplex_node_presync_fxn();

		//Call node presync-equivalent items
		NR_node_presync_fxn();

		//Triplex_load-specific sync calls
			//See if we're reliability-enabled
			if (fault_check_object == NULL)
				fault_mode = false;
			else
				fault_mode = true;

			//Functionalized so deltamode can parttake
			triplex_load_update_fxn();

		//Call sync-equivalent of triplex portion first
		BOTH_triplex_node_sync_fxn();

		//Call node sync-equivalent items (solver occurs at end of sync)
		NR_node_sync_fxn(hdr);

		return SM_DELTA;	//Just return something other than SM_ERROR for this call
	}
	else	//After the call
	{
		//Perform node postsync-like updates on the values
		BOTH_node_postsync_fxn(hdr);

		//Triplex_load-specific postsync items
			measured_voltage_1.SetPolar(voltage1.Mag(),voltage1.Arg());  //Used for testing and xml output
			measured_voltage_2.SetPolar(voltage2.Mag(),voltage2.Arg());
			measured_voltage_12.SetPolar(voltage12.Mag(),voltage12.Arg());

		//No control required at this time - powerflow defers to the whims of other modules
		//Code below implements predictor/corrector-type logic, even though it effectively does nothing
		return SM_EVENT;

		////Do deltamode-related logic
		//if (bustype==SWING)	//We're the SWING bus, control our destiny (which is really controlled elsewhere)
		//{
		//	//See what we're on
		//	pass_mod = iteration_count_val - ((iteration_count_val >> 1) << 1);

		//	//Check pass
		//	if (pass_mod==0)	//Predictor pass
		//	{
		//		return SM_DELTA_ITER;	//Reiterate - to get us to corrector pass
		//	}
		//	else	//Corrector pass
		//	{
		//		//As of right now, we're always ready to leave
		//		//Other objects will dictate if we stay (powerflow is indifferent)
		//		return SM_EVENT;
		//	}//End corrector pass
		//}//End SWING bus handling
		//else	//Normal bus
		//{
		//	return SM_EVENT;	//Normal nodes want event mode all the time here - SWING bus will
		//						//control the reiteration process for pred/corr steps
		//}
	}
}
Beispiel #4
0
//////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION OF DELTA MODE
//////////////////////////////////////////////////////////////////////////
//Module-level call
SIMULATIONMODE triplex_meter::inter_deltaupdate_triplex_meter(unsigned int64 delta_time, unsigned long dt, unsigned int iteration_count_val,bool interupdate_pos)
{
	//unsigned char pass_mod;
	OBJECT *hdr = OBJECTHDR(this);
	int TempNodeRef;

	if (interupdate_pos == false)	//Before powerflow call
	{
		//Triplex meter presync items
			if (tpmeter_power_consumption != complex(0,0))
				power[0] = power[1] = 0.0;

			//Reliability addition - clear momentary flag if set
			if (tpmeter_interrupted_secondary == true)
				tpmeter_interrupted_secondary = false;

		//Call triplex-specific call
		BOTH_triplex_node_presync_fxn();

		//Call node presync-equivalent items
		NR_node_presync_fxn();

		//Triplex-meter specific sync items
			//Reliability check
			if ((fault_check_object != NULL) && (solver_method == SM_NR))	//proper solver fault_check is present (so might need to set flag
			{
				if (NR_node_reference==-99)	//Childed
				{
					TempNodeRef=*NR_subnode_reference;
				}
				else	//Normal
				{
					//Just assign it to our normal index
					TempNodeRef=NR_node_reference;
				}

				if ((NR_busdata[TempNodeRef].origphases & NR_busdata[TempNodeRef].phases) != NR_busdata[TempNodeRef].origphases)	//We have a phase mismatch - something has been lost
				{
					tpmeter_interrupted = true;	//Someone is out of service, they just may not know it

					//See if we were "momentary" as well - if so, clear us.
					if (tpmeter_interrupted_secondary == true)
						tpmeter_interrupted_secondary = false;
				}
				else
				{
					tpmeter_interrupted = false;	//All is well
				}
			}

			if (tpmeter_power_consumption != complex(0,0))
			{
				power[0] += tpmeter_power_consumption/2;
				power[1] += tpmeter_power_consumption/2;
			}

		//Call sync-equivalent of triplex portion first
		BOTH_triplex_node_sync_fxn();

		//Call node sync-equivalent items (solver occurs at end of sync)
		NR_node_sync_fxn(hdr);

		return SM_DELTA;	//Just return something other than SM_ERROR for this call
	}
	else	//After the call
	{
		//Perform node postsync-like updates on the values - call first so current is right
		BOTH_node_postsync_fxn(hdr);

		//Triplex_meter-specific postsync
			measured_voltage[0].SetPolar(voltageA.Mag(),voltageA.Arg());
			measured_voltage[1].SetPolar(voltageB.Mag(),voltageB.Arg());
			measured_voltage[2].SetPolar(voltageC.Mag(),voltageC.Arg());

			measured_current[0] = current_inj[0];
			measured_current[1] = current_inj[1];
			measured_current[2] = -(measured_current[1]+measured_current[0]);

			indiv_measured_power[0] = measured_voltage[0]*(~measured_current[0]);
			indiv_measured_power[1] = complex(-1,0) * measured_voltage[1]*(~measured_current[1]);
			indiv_measured_power[2] = measured_voltage[2]*(~measured_current[2]);

			measured_power = indiv_measured_power[0] + indiv_measured_power[1] + indiv_measured_power[2];

			measured_real_power = (indiv_measured_power[0]).Re()
								+ (indiv_measured_power[1]).Re()
								+ (indiv_measured_power[2]).Re();

			measured_reactive_power = (indiv_measured_power[0]).Im()
									+ (indiv_measured_power[1]).Im()
									+ (indiv_measured_power[2]).Im();

			if (measured_real_power>measured_demand)
				measured_demand=measured_real_power;

		//No control required at this time - powerflow defers to the whims of other modules
		//Code below implements predictor/corrector-type logic, even though it effectively does nothing
		return SM_EVENT;

		////Do deltamode-related logic
		//if (bustype==SWING)	//We're the SWING bus, control our destiny (which is really controlled elsewhere)
		//{
		//	//See what we're on
		//	pass_mod = iteration_count_val - ((iteration_count_val >> 1) << 1);

		//	//Check pass
		//	if (pass_mod==0)	//Predictor pass
		//	{
		//		return SM_DELTA_ITER;	//Reiterate - to get us to corrector pass
		//	}
		//	else	//Corrector pass
		//	{
		//		//As of right now, we're always ready to leave
		//		//Other objects will dictate if we stay (powerflow is indifferent)
		//		return SM_EVENT;
		//	}//End corrector pass
		//}//End SWING bus handling
		//else	//Normal bus
		//{
		//	return SM_EVENT;	//Normal nodes want event mode all the time here - SWING bus will
		//						//control the reiteration process for pred/corr steps
		//}
	}
}