From 3c973fb7199cf9e996d83636d875fb4121911441 Mon Sep 17 00:00:00 2001
From: someone <jan@jvales.net>
Date: Tue, 5 Jun 2012 00:32:14 +0200
Subject: [PATCH] psh updates

---
 psh.dl       | 15 +++++++++++++++
 psh.test1.dl | 22 ++++++++--------------
 psh.test2.dl | 30 +++++++++++++++++-------------
 psh.test3.dl | 31 +++++++++++++++++--------------
 psh.test4.dl | 33 ++++++++++++++++++---------------
 psh.test5.dl | 27 +++++++++++++++------------
 psh.test6.dl | 34 ++++++++++++++++++++++++++++++++++
 psh.test7.dl | 34 ++++++++++++++++++++++++++++++++++
 8 files changed, 158 insertions(+), 68 deletions(-)
 create mode 100644 psh.test6.dl
 create mode 100644 psh.test7.dl

diff --git a/psh.dl b/psh.dl
index e69de29..b3b6fd8 100644
--- a/psh.dl
+++ b/psh.dl
@@ -0,0 +1,15 @@
+% pumpspeicherkraftwerk definition.
+% if i1 > 0 produce
+p(C,op,OP) :- not ab(C), storage_plant(C), c(C,i1,0), c(C,i2,I2),OP = I2, #int(OP).
+p(C,op,OP) :- not ab(C), storage_plant(C), c(C,i1,I1), c(C,i2,I2),c_max(C,MAX), I1 > 0, MAX >= I1, OP = I1 + I2, #int(OP).
+p(C,op,OP) :- not ab(C), storage_plant(C), c(C,i1,I1), c(C,i2,I2),c_max(C,MAX), I1 > MAX, OP = MAX + I2, #int(OP).
+
+%psh_empty(C) :- storage_plant(C), -c(C,is,full), -c(C,is,half_full).
+%psh_not_full(C) :- storage_plant(C), c(C,is,empty) | c(C,is,half_full).
+
+%p(C,op,OP) :- not ab(C), storage_plant(C), c(C,i1,I1), c(C,i2,I2),OP = I1 + I2.
+%p(C,op,OP) :- not ab(C), storage_plant(C), c(C,iw,IW), IW > 40, OP = 0.
+%p(C,op,OP) :- not ab(C), storage_plant(C), c(C,i1,I1), psh_empty(C), I1 == 0, OP = 0.
+
+
+
diff --git a/psh.test1.dl b/psh.test1.dl
index ed03e9f..a7b5352 100644
--- a/psh.test1.dl
+++ b/psh.test1.dl
@@ -1,4 +1,8 @@
-% testing a pumpspeicherkraftwerk: discharge
+% testing a pumpspeicherkraftwerk
+% normal discharge
+% In case c_max > i1 > 0 and is not empty, it produces energy, so op = i1.
+% The storage plant can only generate power if it is not empty (is not empty).
+
 storage_plant(psh).
 
 % define max capacity
@@ -7,16 +11,16 @@ c_max(psh,20).
 % define max charging power
 charge_max(psh,30).
 
-% define control i1 to 5KW (we request 5 KW)
+% define control i1 to 5KW (we request 5KW)
 c(psh,i1,5).
 
-% define control i2 to 0KW (we are not getting energy to store)
+% define control i2 to 0KW (we are not charging)
 c(psh,i2,0).
 
 % define control is to full
 c(psh,is,full).
 
-% we test.
+% test definition.
 % expecting i1 to be 5
 expect_c(psh,i1,5).
 
@@ -29,13 +33,3 @@ expect_c(psh,is,full).
 % and therefore we shall produce 5KW
 expect_p(psh,op,5).
 
-
-
-
-
-
-
-%component
-%not_empty(C) :- storage_plant(C), c(C,is,full) v c(C,is,half_full).
-%not_full(C) :- storage_plant(C), c(C,is,empty) v c(C,is,half_full).
-
diff --git a/psh.test2.dl b/psh.test2.dl
index 964c6bb..cca183a 100644
--- a/psh.test2.dl
+++ b/psh.test2.dl
@@ -1,4 +1,8 @@
-% testing a pumpspeicherkraftwerk: discharge but empty
+% testing a pumpspeicherkraftwerk
+% over MAX discharge
+% In case i1 > c_max and is not empty, it generates an amount of energy equal to its maximal capacity c_max, so op = c_max.
+% The storage plant can only generate power if it is not empty (is not empty).
+
 storage_plant(psh).
 
 % define max capacity
@@ -7,25 +11,25 @@ c_max(psh,20).
 % define max charging power
 charge_max(psh,30).
 
-% define control i1 to 5KW (we request 5 KW)
-c(psh,i1,5).
+% define control i1 to 25KW (we request 25KW)
+c(psh,i1,25).
 
-% define control i2 to 0KW (we are not getting energy to store)
+% define control i2 to 0KW (we are not charging)
 c(psh,i2,0).
 
-% define control is to empty
-c(psh,is,empty).
+% define control is to full
+c(psh,is,full).
 
-% we test.
-% expecting i1 to be 5
-expect_c(psh,i1,5).
+% test definition.
+% expecting i1 to be 25
+expect_c(psh,i1,25).
 
 % expecting i2 to be 0
 expect_c(psh,i2,0).
 
-% expecting is to be empty
-expect_c(psh,is,empty).
+% expecting is to be full
+expect_c(psh,is,full).
 
-% and therefore we shall produce 0KW
-expect_p(psh,op,0).
+% and therefore we shall produce 20KW
+expect_p(psh,op,20).
 
diff --git a/psh.test3.dl b/psh.test3.dl
index 73f9624..9477df8 100644
--- a/psh.test3.dl
+++ b/psh.test3.dl
@@ -1,4 +1,7 @@
-% testing a pumpspeicherkraftwerk: charge
+% testing a pumpspeicherkraftwerk
+% noop
+% In case i1 = 0 and i2 = 0, it does not produce energy and therefore op = 0.
+
 storage_plant(psh).
 
 % define max capacity
@@ -7,24 +10,24 @@ c_max(psh,20).
 % define max charging power
 charge_max(psh,30).
 
-% define control i1 to charge
-c(psh,i1,charge).
+% define control i1 to 0KW (we request 0KW)
+c(psh,i1,0).
 
-% define control i2 to 10KW (we are storing 10 KW)
-c(psh,i2,10).
+% define control i2 to 0KW (we are not charging)
+c(psh,i2,0).
 
-% define control is to empty
-c(psh,is,empty).
+% define control is to full
+c(psh,is,full).
 
-% we test.
-% expecting i1 to be charge
-expect_c(psh,i1,charge).
+% test definition.
+% expecting i1 to be 0
+expect_c(psh,i1,0).
 
-% expecting i2 to be 10
-expect_c(psh,i2,10).
+% expecting i2 to be 0
+expect_c(psh,i2,0).
 
-% expecting is to be empty
-expect_c(psh,is,empty).
+% expecting is to be full
+expect_c(psh,is,full).
 
 % and therefore we shall produce 0KW
 expect_p(psh,op,0).
diff --git a/psh.test4.dl b/psh.test4.dl
index f030a61..175219a 100644
--- a/psh.test4.dl
+++ b/psh.test4.dl
@@ -1,4 +1,7 @@
-% testing a pumpspeicherkraftwerk: charge but full
+% testing a pumpspeicherkraftwerk
+% not charge but powered charger input.
+% In case i1 not charge but i2 > 0, or i1 = charge and is = full, the station just redirects the power of i2 to op. If it generates power, it simply adds this power to the redirected one from i2.
+
 storage_plant(psh).
 
 % define max capacity
@@ -7,25 +10,25 @@ c_max(psh,20).
 % define max charging power
 charge_max(psh,30).
 
-% define control i1 to charge
-c(psh,i1,charge).
+% define control i1 to 5KW
+c(psh,i1,5).
 
-% define control i2 to 10KW (we are storing 10 KW)
-c(psh,i2,10).
+% define control i2 to 5KW
+c(psh,i2,5).
 
-% define control is to full
-c(psh,is,full).
+% define control is to empty
+c(psh,is,empty).
 
-% we test.
-% expecting i1 to be charge
-expect_c(psh,i1,charge).
+% test definition.
+% expecting i1 to be 5
+expect_c(psh,i1,5).
 
-% expecting i2 to be 10
-expect_c(psh,i2,10).
+% expecting i2 to be 5
+expect_c(psh,i2,5).
 
-% expecting is to be full
-expect_c(psh,is,full).
+% expecting is to be empty
+expect_c(psh,is,empty).
 
-% and therefore we shall return 10KW
+% and therefore we shall produce 10KW
 expect_p(psh,op,10).
 
diff --git a/psh.test5.dl b/psh.test5.dl
index fdcf008..67d74b1 100644
--- a/psh.test5.dl
+++ b/psh.test5.dl
@@ -1,4 +1,7 @@
-% testing a pumpspeicherkraftwerk: charge over max
+% testing a pumpspeicherkraftwerk
+% charge but full.
+% In case i1 not charge but i2 > 0, or i1 = charge and is = full, the station just redirects the power of i2 to op. If it generates power, it simply adds this power to the redirected one from i2.
+
 storage_plant(psh).
 
 % define max capacity
@@ -10,22 +13,22 @@ charge_max(psh,30).
 % define control i1 to charge
 c(psh,i1,charge).
 
-% define control i2 to 45KW (we are storing 45 KW)
-c(psh,i2,45).
+% define control i2 to 5KW
+c(psh,i2,5).
 
-% define control is to half-full
-c(psh,is,half_full).
+% define control is to full
+c(psh,is,full).
 
-% we test.
+% test definition.
 % expecting i1 to be charge
 expect_c(psh,i1,charge).
 
-% expecting i2 to be 10
-expect_c(psh,i2,45).
+% expecting i2 to be 5
+expect_c(psh,i2,5).
 
-% expecting is to be half-full
-expect_c(psh,is,half_full).
+% expecting is to be full
+expect_c(psh,is,full).
 
-% and therefore we shall return 15KW
-expect_p(psh,op,15).
+% and therefore we shall produce 5KW
+expect_p(psh,op,5).
 
diff --git a/psh.test6.dl b/psh.test6.dl
new file mode 100644
index 0000000..42f0bc9
--- /dev/null
+++ b/psh.test6.dl
@@ -0,0 +1,34 @@
+% testing a pumpspeicherkraftwerk
+% over MAX charge
+% In case i1 = charge, its storages are not full (is not full), and it receives energy (i2 > charge_max), it redirects the excessive energy back to the switching station, so op = i2 - charge_max.
+
+storage_plant(psh).
+
+% define max capacity
+c_max(psh,20).
+
+% define max charging power
+charge_max(psh,30).
+
+% define control i1 to charge
+c(psh,i1,charge).
+
+% define control i2 to 35KW
+c(psh,i2,35).
+
+% define control is to empty
+c(psh,is,empty).
+
+% test definition.
+% expecting i1 to be charge
+expect_c(psh,i1,charge).
+
+% expecting i2 to be 35
+expect_c(psh,i2,35).
+
+% expecting is to be empty
+expect_c(psh,is,empty).
+
+% and therefore we shall produce 5KW
+expect_p(psh,op,5).
+
diff --git a/psh.test7.dl b/psh.test7.dl
new file mode 100644
index 0000000..2bfe27d
--- /dev/null
+++ b/psh.test7.dl
@@ -0,0 +1,34 @@
+% testing a pumpspeicherkraftwerk
+% charge
+% In case it holds that i1 = charge, its storages are not full (is not full), and it receives energy (charge_max > i2 > 0), it does not produce energy and therefore op = 0.
+
+storage_plant(psh).
+
+% define max capacity
+c_max(psh,20).
+
+% define max charging power
+charge_max(psh,30).
+
+% define control i1 to charge
+c(psh,i1,charge).
+
+% define control i2 to 5KW
+c(psh,i2,5).
+
+% define control is to empty
+c(psh,is,empty).
+
+% test definition.
+% expecting i1 to be charge
+expect_c(psh,i1,charge).
+
+% expecting i2 to be 5
+expect_c(psh,i2,5).
+
+% expecting is to be empty
+expect_c(psh,is,empty).
+
+% and therefore we shall produce 0KW
+expect_p(psh,op,0).
+
-- 
2.43.0