ch.ninecode.model.AsynchronousMachineDynamics.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CIMReader Show documentation
Show all versions of CIMReader Show documentation
Expose CIM data files as Spark RDD
package ch.ninecode.model
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.Serializer
import com.esotericsoftware.kryo.io.Input
import com.esotericsoftware.kryo.io.Output
import org.apache.spark.sql.Row
import ch.ninecode.cim.CIMClassInfo
import ch.ninecode.cim.CIMContext
import ch.ninecode.cim.CIMParseable
import ch.ninecode.cim.CIMRelationship
import ch.ninecode.cim.CIMSerializer
/**
* Asynchronous machine whose behaviour is described by reference to a standard model expressed in either time constant reactance form or equivalent circuit form or by definition of a user-defined model.
* Parameter details:
*
* - Asynchronous machine parameters such as Xl, Xs, etc. are actually used as inductances in the model, but are commonly referred to as reactances since, at nominal frequency, the PU values are the same.
*
* However, some references use the symbol L instead of X.
*
*
* @param RotatingMachineDynamics [[ch.ninecode.model.RotatingMachineDynamics RotatingMachineDynamics]] Reference to the superclass object.
* @param AsynchronousMachine [[ch.ninecode.model.AsynchronousMachine AsynchronousMachine]] Asynchronous machine to which this asynchronous machine dynamics model applies.
* @param MechanicalLoadDynamics [[ch.ninecode.model.MechanicalLoadDynamics MechanicalLoadDynamics]] Mechanical load model associated with this asynchronous machine model.
* @param TurbineGovernorDynamics [[ch.ninecode.model.TurbineGovernorDynamics TurbineGovernorDynamics]] Turbine-governor model associated with this asynchronous machine model.
* @param WindTurbineType1or2Dynamics [[ch.ninecode.model.WindTurbineType1or2Dynamics WindTurbineType1or2Dynamics]] Wind generator type 1 or type 2 model associated with this asynchronous machine model.
* @group AsynchronousMachineDynamics
* @groupname AsynchronousMachineDynamics Package AsynchronousMachineDynamics
* @groupdesc AsynchronousMachineDynamics An asynchronous machine model represents a (induction) generator or motor with no external connection to the rotor windings, e.g. a squirrel-cage induction machine.
The interconnection with the electrical network equations can differ among simulation tools. The program only needs to know the terminal to which this asynchronous machine is connected in order to establish the correct interconnection. The interconnection with the motor’s equipment could also differ due to input and output signals required by standard models.
The asynchronous machine model is used to model wind generators type 1 and type 2. For these, normal practice is to include the rotor flux transients and neglect the stator flux transients.
*/
final case class AsynchronousMachineDynamics
(
RotatingMachineDynamics: RotatingMachineDynamics = null,
AsynchronousMachine: String = null,
MechanicalLoadDynamics: String = null,
TurbineGovernorDynamics: String = null,
WindTurbineType1or2Dynamics: String = null
)
extends
Element
{
/**
* Return the superclass object.
*
* @return The typed superclass nested object.
* @group Hierarchy
* @groupname Hierarchy Class Hierarchy Related
* @groupdesc Hierarchy Members related to the nested hierarchy of CIM classes.
*/
override def sup: RotatingMachineDynamics = RotatingMachineDynamics
//
// Row overrides
//
/**
* Return a copy of this object as a Row.
*
* Creates a clone of this object for use in Row manipulations.
*
* @return The copy of the object.
* @group Row
* @groupname Row SQL Row Implementation
* @groupdesc Row Members related to implementing the SQL Row interface
*/
override def copy (): Row = { clone ().asInstanceOf[Row] }
override def export_fields: String =
{
implicit val s: StringBuilder = new StringBuilder (sup.export_fields)
implicit val clz: String = AsynchronousMachineDynamics.cls
def emitattr (position: Int, value: Any): Unit = if (mask (position)) emit_attribute (AsynchronousMachineDynamics.fields (position), value)
emitattr (0, AsynchronousMachine)
emitattr (1, MechanicalLoadDynamics)
emitattr (2, TurbineGovernorDynamics)
emitattr (3, WindTurbineType1or2Dynamics)
s.toString
}
override def export: String =
{
"\t\n%s\t ".format (id, export_fields)
}
}
object AsynchronousMachineDynamics
extends
CIMParseable[AsynchronousMachineDynamics]
{
override val fields: Array[String] = Array[String] (
"AsynchronousMachine",
"MechanicalLoadDynamics",
"TurbineGovernorDynamics",
"WindTurbineType1or2Dynamics"
)
override val relations: List[CIMRelationship] = List (
CIMRelationship ("AsynchronousMachine", "AsynchronousMachine", "1", "0..1"),
CIMRelationship ("MechanicalLoadDynamics", "MechanicalLoadDynamics", "0..1", "0..1"),
CIMRelationship ("TurbineGovernorDynamics", "TurbineGovernorDynamics", "0..1", "0..1"),
CIMRelationship ("WindTurbineType1or2Dynamics", "WindTurbineType1or2Dynamics", "0..1", "1")
)
val AsynchronousMachine: Fielder = parse_attribute (attribute (cls, fields(0)))
val MechanicalLoadDynamics: Fielder = parse_attribute (attribute (cls, fields(1)))
val TurbineGovernorDynamics: Fielder = parse_attribute (attribute (cls, fields(2)))
val WindTurbineType1or2Dynamics: Fielder = parse_attribute (attribute (cls, fields(3)))
def parse (context: CIMContext): AsynchronousMachineDynamics =
{
implicit val ctx: CIMContext = context
implicit val bitfields: Array[Int] = Array(0)
val ret = AsynchronousMachineDynamics (
RotatingMachineDynamics.parse (context),
mask (AsynchronousMachine (), 0),
mask (MechanicalLoadDynamics (), 1),
mask (TurbineGovernorDynamics (), 2),
mask (WindTurbineType1or2Dynamics (), 3)
)
ret.bitfields = bitfields
ret
}
def serializer: Serializer[AsynchronousMachineDynamics] = AsynchronousMachineDynamicsSerializer
}
object AsynchronousMachineDynamicsSerializer extends CIMSerializer[AsynchronousMachineDynamics]
{
def write (kryo: Kryo, output: Output, obj: AsynchronousMachineDynamics): Unit =
{
val toSerialize: Array[() => Unit] = Array (
() => output.writeString (obj.AsynchronousMachine),
() => output.writeString (obj.MechanicalLoadDynamics),
() => output.writeString (obj.TurbineGovernorDynamics),
() => output.writeString (obj.WindTurbineType1or2Dynamics)
)
RotatingMachineDynamicsSerializer.write (kryo, output, obj.sup)
implicit val bitfields: Array[Int] = obj.bitfields
writeBitfields (output)
writeFields (toSerialize)
}
def read (kryo: Kryo, input: Input, cls: Class[AsynchronousMachineDynamics]): AsynchronousMachineDynamics =
{
val parent = RotatingMachineDynamicsSerializer.read (kryo, input, classOf[RotatingMachineDynamics])
implicit val bitfields: Array[Int] = readBitfields (input)
val obj = AsynchronousMachineDynamics (
parent,
if (isSet (0)) input.readString else null,
if (isSet (1)) input.readString else null,
if (isSet (2)) input.readString else null,
if (isSet (3)) input.readString else null
)
obj.bitfields = bitfields
obj
}
}
/**
* The electrical equations of all variations of the asynchronous model are based on the AsynchronousEquivalentCircuit diagram for the direct- and quadrature- axes, with two equivalent rotor windings in each axis.
*
* Equations for conversion between equivalent circuit and time constant reactance forms:
* Xs = Xm + Xl
* X' = Xl + Xm x Xlr1 / (Xm + Xlr1)
* X'' = Xl + Xm x Xlr1 x Xlr2 / (Xm x Xlr1 + Xm x Xlr2 + Xlr1 x Xlr2)
* T'o = (Xm + Xlr1) / (omega0 x Rr1)
* T''o = (Xm x Xlr1 + Xm x Xlr2 + Xlr1 x Xlr2) / (omega0 x Rr2 x (Xm + Xlr1)
* Same equations using CIM attributes from AsynchronousMachineTimeConstantReactance class on left of "=" and AsynchronousMachineEquivalentCircuit class on right (except as noted):
* xs = xm + RotatingMachineDynamics.statorLeakageReactance
* xp = RotatingMachineDynamics.statorLeakageReactance + xm x xlr1 / (xm + xlr1)
* xpp = RotatingMachineDynamics.statorLeakageReactance + xm x xlr1 x xlr2 / (xm x xlr1 + xm x xlr2 + xlr1 x xlr2)
* tpo = (xm + xlr1) / (2 x pi x nominal frequency x rr1)
* tppo = (xm x xlr1 + xm x xlr2 + xlr1 x xlr2) / (2 x pi x nominal frequency x rr2 x (xm + xlr1).
*
* @param AsynchronousMachineDynamics [[ch.ninecode.model.AsynchronousMachineDynamics AsynchronousMachineDynamics]] Reference to the superclass object.
* @param rr1 Damper 1 winding resistance.
* @param rr2 Damper 2 winding resistance.
* @param xlr1 Damper 1 winding leakage reactance.
* @param xlr2 Damper 2 winding leakage reactance.
* @param xm Magnetizing reactance.
* @group AsynchronousMachineDynamics
* @groupname AsynchronousMachineDynamics Package AsynchronousMachineDynamics
* @groupdesc AsynchronousMachineDynamics An asynchronous machine model represents a (induction) generator or motor with no external connection to the rotor windings, e.g. a squirrel-cage induction machine.
The interconnection with the electrical network equations can differ among simulation tools. The program only needs to know the terminal to which this asynchronous machine is connected in order to establish the correct interconnection. The interconnection with the motor’s equipment could also differ due to input and output signals required by standard models.
The asynchronous machine model is used to model wind generators type 1 and type 2. For these, normal practice is to include the rotor flux transients and neglect the stator flux transients.
*/
final case class AsynchronousMachineEquivalentCircuit
(
AsynchronousMachineDynamics: AsynchronousMachineDynamics = null,
rr1: Double = 0.0,
rr2: Double = 0.0,
xlr1: Double = 0.0,
xlr2: Double = 0.0,
xm: Double = 0.0
)
extends
Element
{
/**
* Return the superclass object.
*
* @return The typed superclass nested object.
* @group Hierarchy
* @groupname Hierarchy Class Hierarchy Related
* @groupdesc Hierarchy Members related to the nested hierarchy of CIM classes.
*/
override def sup: AsynchronousMachineDynamics = AsynchronousMachineDynamics
//
// Row overrides
//
/**
* Return a copy of this object as a Row.
*
* Creates a clone of this object for use in Row manipulations.
*
* @return The copy of the object.
* @group Row
* @groupname Row SQL Row Implementation
* @groupdesc Row Members related to implementing the SQL Row interface
*/
override def copy (): Row = { clone ().asInstanceOf[Row] }
override def export_fields: String =
{
implicit val s: StringBuilder = new StringBuilder (sup.export_fields)
implicit val clz: String = AsynchronousMachineEquivalentCircuit.cls
def emitelem (position: Int, value: Any): Unit = if (mask (position)) emit_element (AsynchronousMachineEquivalentCircuit.fields (position), value)
emitelem (0, rr1)
emitelem (1, rr2)
emitelem (2, xlr1)
emitelem (3, xlr2)
emitelem (4, xm)
s.toString
}
override def export: String =
{
"\t\n%s\t ".format (id, export_fields)
}
}
object AsynchronousMachineEquivalentCircuit
extends
CIMParseable[AsynchronousMachineEquivalentCircuit]
{
override val fields: Array[String] = Array[String] (
"rr1",
"rr2",
"xlr1",
"xlr2",
"xm"
)
val rr1: Fielder = parse_element (element (cls, fields(0)))
val rr2: Fielder = parse_element (element (cls, fields(1)))
val xlr1: Fielder = parse_element (element (cls, fields(2)))
val xlr2: Fielder = parse_element (element (cls, fields(3)))
val xm: Fielder = parse_element (element (cls, fields(4)))
def parse (context: CIMContext): AsynchronousMachineEquivalentCircuit =
{
implicit val ctx: CIMContext = context
implicit val bitfields: Array[Int] = Array(0)
val ret = AsynchronousMachineEquivalentCircuit (
AsynchronousMachineDynamics.parse (context),
toDouble (mask (rr1 (), 0)),
toDouble (mask (rr2 (), 1)),
toDouble (mask (xlr1 (), 2)),
toDouble (mask (xlr2 (), 3)),
toDouble (mask (xm (), 4))
)
ret.bitfields = bitfields
ret
}
def serializer: Serializer[AsynchronousMachineEquivalentCircuit] = AsynchronousMachineEquivalentCircuitSerializer
}
object AsynchronousMachineEquivalentCircuitSerializer extends CIMSerializer[AsynchronousMachineEquivalentCircuit]
{
def write (kryo: Kryo, output: Output, obj: AsynchronousMachineEquivalentCircuit): Unit =
{
val toSerialize: Array[() => Unit] = Array (
() => output.writeDouble (obj.rr1),
() => output.writeDouble (obj.rr2),
() => output.writeDouble (obj.xlr1),
() => output.writeDouble (obj.xlr2),
() => output.writeDouble (obj.xm)
)
AsynchronousMachineDynamicsSerializer.write (kryo, output, obj.sup)
implicit val bitfields: Array[Int] = obj.bitfields
writeBitfields (output)
writeFields (toSerialize)
}
def read (kryo: Kryo, input: Input, cls: Class[AsynchronousMachineEquivalentCircuit]): AsynchronousMachineEquivalentCircuit =
{
val parent = AsynchronousMachineDynamicsSerializer.read (kryo, input, classOf[AsynchronousMachineDynamics])
implicit val bitfields: Array[Int] = readBitfields (input)
val obj = AsynchronousMachineEquivalentCircuit (
parent,
if (isSet (0)) input.readDouble else 0.0,
if (isSet (1)) input.readDouble else 0.0,
if (isSet (2)) input.readDouble else 0.0,
if (isSet (3)) input.readDouble else 0.0,
if (isSet (4)) input.readDouble else 0.0
)
obj.bitfields = bitfields
obj
}
}
/**
* Parameter details:
*
* - If X'' = X', a single cage (one equivalent rotor winding per axis) is modelled.
* - The “p” in the attribute names is a substitution for a “prime” in the usual parameter notation, e.g. tpo refers to T'o.
*
* The parameters used for models expressed in time constant reactance form include:
* - RotatingMachine.ratedS (MVAbase);
* - RotatingMachineDynamics.damping (D);
* - RotatingMachineDynamics.inertia (H);
* - RotatingMachineDynamics.saturationFactor (S1);
* - RotatingMachineDynamics.saturationFactor120 (S12);
* - RotatingMachineDynamics.statorLeakageReactance (Xl);
* - RotatingMachineDynamics.statorResistance (Rs);
* - .xs (Xs);
* - .xp (X');
* - .xpp (X'');
* - .tpo (T'o);
*
* - .tppo (T''o).
*
* @param AsynchronousMachineDynamics [[ch.ninecode.model.AsynchronousMachineDynamics AsynchronousMachineDynamics]] Reference to the superclass object.
* @param tpo Transient rotor time constant (T'o) (> AsynchronousMachineTimeConstantReactance.tppo).
* Typical value = 5.
* @param tppo Subtransient rotor time constant (T''o) (> 0).
* Typical value = 0,03.
* @param xp Transient reactance (unsaturated) (X') (>= AsynchronousMachineTimeConstantReactance.xpp).
* Typical value = 0,5.
* @param xpp Subtransient reactance (unsaturated) (X'') (> RotatingMachineDynamics.statorLeakageReactance).
* Typical value = 0,2.
* @param xs Synchronous reactance (Xs) (>= AsynchronousMachineTimeConstantReactance.xp).
* Typical value = 1,8.
* @group AsynchronousMachineDynamics
* @groupname AsynchronousMachineDynamics Package AsynchronousMachineDynamics
* @groupdesc AsynchronousMachineDynamics An asynchronous machine model represents a (induction) generator or motor with no external connection to the rotor windings, e.g. a squirrel-cage induction machine.
The interconnection with the electrical network equations can differ among simulation tools. The program only needs to know the terminal to which this asynchronous machine is connected in order to establish the correct interconnection. The interconnection with the motor’s equipment could also differ due to input and output signals required by standard models.
The asynchronous machine model is used to model wind generators type 1 and type 2. For these, normal practice is to include the rotor flux transients and neglect the stator flux transients.
*/
final case class AsynchronousMachineTimeConstantReactance
(
AsynchronousMachineDynamics: AsynchronousMachineDynamics = null,
tpo: Double = 0.0,
tppo: Double = 0.0,
xp: Double = 0.0,
xpp: Double = 0.0,
xs: Double = 0.0
)
extends
Element
{
/**
* Return the superclass object.
*
* @return The typed superclass nested object.
* @group Hierarchy
* @groupname Hierarchy Class Hierarchy Related
* @groupdesc Hierarchy Members related to the nested hierarchy of CIM classes.
*/
override def sup: AsynchronousMachineDynamics = AsynchronousMachineDynamics
//
// Row overrides
//
/**
* Return a copy of this object as a Row.
*
* Creates a clone of this object for use in Row manipulations.
*
* @return The copy of the object.
* @group Row
* @groupname Row SQL Row Implementation
* @groupdesc Row Members related to implementing the SQL Row interface
*/
override def copy (): Row = { clone ().asInstanceOf[Row] }
override def export_fields: String =
{
implicit val s: StringBuilder = new StringBuilder (sup.export_fields)
implicit val clz: String = AsynchronousMachineTimeConstantReactance.cls
def emitelem (position: Int, value: Any): Unit = if (mask (position)) emit_element (AsynchronousMachineTimeConstantReactance.fields (position), value)
emitelem (0, tpo)
emitelem (1, tppo)
emitelem (2, xp)
emitelem (3, xpp)
emitelem (4, xs)
s.toString
}
override def export: String =
{
"\t\n%s\t ".format (id, export_fields)
}
}
object AsynchronousMachineTimeConstantReactance
extends
CIMParseable[AsynchronousMachineTimeConstantReactance]
{
override val fields: Array[String] = Array[String] (
"tpo",
"tppo",
"xp",
"xpp",
"xs"
)
val tpo: Fielder = parse_element (element (cls, fields(0)))
val tppo: Fielder = parse_element (element (cls, fields(1)))
val xp: Fielder = parse_element (element (cls, fields(2)))
val xpp: Fielder = parse_element (element (cls, fields(3)))
val xs: Fielder = parse_element (element (cls, fields(4)))
def parse (context: CIMContext): AsynchronousMachineTimeConstantReactance =
{
implicit val ctx: CIMContext = context
implicit val bitfields: Array[Int] = Array(0)
val ret = AsynchronousMachineTimeConstantReactance (
AsynchronousMachineDynamics.parse (context),
toDouble (mask (tpo (), 0)),
toDouble (mask (tppo (), 1)),
toDouble (mask (xp (), 2)),
toDouble (mask (xpp (), 3)),
toDouble (mask (xs (), 4))
)
ret.bitfields = bitfields
ret
}
def serializer: Serializer[AsynchronousMachineTimeConstantReactance] = AsynchronousMachineTimeConstantReactanceSerializer
}
object AsynchronousMachineTimeConstantReactanceSerializer extends CIMSerializer[AsynchronousMachineTimeConstantReactance]
{
def write (kryo: Kryo, output: Output, obj: AsynchronousMachineTimeConstantReactance): Unit =
{
val toSerialize: Array[() => Unit] = Array (
() => output.writeDouble (obj.tpo),
() => output.writeDouble (obj.tppo),
() => output.writeDouble (obj.xp),
() => output.writeDouble (obj.xpp),
() => output.writeDouble (obj.xs)
)
AsynchronousMachineDynamicsSerializer.write (kryo, output, obj.sup)
implicit val bitfields: Array[Int] = obj.bitfields
writeBitfields (output)
writeFields (toSerialize)
}
def read (kryo: Kryo, input: Input, cls: Class[AsynchronousMachineTimeConstantReactance]): AsynchronousMachineTimeConstantReactance =
{
val parent = AsynchronousMachineDynamicsSerializer.read (kryo, input, classOf[AsynchronousMachineDynamics])
implicit val bitfields: Array[Int] = readBitfields (input)
val obj = AsynchronousMachineTimeConstantReactance (
parent,
if (isSet (0)) input.readDouble else 0.0,
if (isSet (1)) input.readDouble else 0.0,
if (isSet (2)) input.readDouble else 0.0,
if (isSet (3)) input.readDouble else 0.0,
if (isSet (4)) input.readDouble else 0.0
)
obj.bitfields = bitfields
obj
}
}
private[ninecode] object _AsynchronousMachineDynamics
{
def register: List[CIMClassInfo] =
{
List (
AsynchronousMachineDynamics.register,
AsynchronousMachineEquivalentCircuit.register,
AsynchronousMachineTimeConstantReactance.register
)
}
}