-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11c13a5
commit cfec04e
Showing
6 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[*.{kt,kts}] | ||
max_line_length = 120 | ||
ktlint_code_style = ktlint_official |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.github.statnett.loadflowservice | ||
|
||
import com.powsybl.iidm.network.Network | ||
|
||
/** | ||
* Class for holding properties from the PowsbyBl bus class that are | ||
* returned via the Rest API | ||
*/ | ||
data class BusProperties( | ||
val id: String, | ||
val voltage: Double, | ||
val angle: Double, | ||
val activePower: Double, | ||
val reactivePower: Double, | ||
) | ||
|
||
fun busPropertiesFromNetwork(network: Network) = | ||
network.getBusView().getBusStream().map { | ||
BusProperties( | ||
id = it.getId(), | ||
voltage = it.getV(), | ||
angle = it.getAngle(), | ||
activePower = it.getP(), | ||
reactivePower = it.getQ(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
package com.github.statnett.loadflowservice | ||
|
||
import com.powsybl.iidm.network.Network | ||
import com.powsybl.loadflow.LoadFlowParameters | ||
import com.powsybl.loadflow.LoadFlow | ||
import com.powsybl.loadflow.LoadFlowParameters | ||
import java.io.InputStream | ||
|
||
fun networkFromStream(fname: String, content: InputStream): Network { | ||
fun networkFromStream( | ||
fname: String, | ||
content: InputStream, | ||
): Network { | ||
return Network.read(fname, content) | ||
} | ||
} | ||
|
||
fun solve(network: Network, parameters: LoadFlowParameters) { | ||
LoadFlow.run(network, parameters); | ||
} | ||
fun solve( | ||
network: Network, | ||
parameters: LoadFlowParameters, | ||
) { | ||
LoadFlow.run(network, parameters) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory | ||
import com.github.statnett.loadflowservice.busPropertiesFromNetwork | ||
|
||
class ApiDataModelTest { | ||
|
||
@Test | ||
fun `Should be 14 buses in test network`() { | ||
val network = IeeeCdfNetworkFactory.create14() | ||
val buses = busPropertiesFromNetwork(network) | ||
assertEquals(buses.count(), 14) | ||
} | ||
} |