Power function errors

Dear all,


I have troubles with Power function and I really need help. I can’t use ** operator since the base is negative and when I am trying to write for example:

power(log((t(DHWater)+273.15)/647.096),2)

I am getting errors 121, 148, 8 and so on… I can’t figure out this 121 error “Set expected” which is coming immediately after log function.

Please find relevant part of code included below.


Cheers,

Davor



Sets

u UNITS /HPST1
LPST1
HPST2
LPST2
GT1
GT2
HEhot
HEcold
ECONOMISER1
EVAPORATOR1
SUPERHEATER1
HRSG
ECONOMISER2
EVAPORATOR2
SUPERHEATER2
BURNER
CONDENSER/

new(u) /HPST1
LPST1
HPST2
LPST2
GT1
GT2
HRSG
ECONOMISER2
EVAPORATOR2
SUPERHEATER2/

ST(u) /HPST1
LPST1
HPST2
LPST2/

GT(u) /GT1
GT2/

s STREAMS /coal
NG1
NG2
Air1
Air2
Air3
EXG1
FG1
FG2
FG3
FG4
FG5
FG6
FG7
FG8
FG9
FG10
DHW0
DHW1
DHW2
SatS1
SatS3
SuperS1
SuperS2
SuperS21
SuperS22
SuperS3
SuperS4
SuperS41
SuperS42
SuperS5
WetS1
WetS2
WetS3
WetS4
FW00
FW01
FW02
FW03
FW04
FW2
FW3
FW4
FW5
FWHE1
FWHE2
FWHE21
FWHE3
FWHE31
ELECTRICITY/

FWwater(s) /FW00
FW01
FW02
FW03
FW04
FW3
FW5
FWHE1
FWHE2
FWHE21
FWHE3
FWHE31/

FWsum(s) /FW2
FW4/

DHwater(s) /DHW0
DHW1
DHW2/

fuel(s) /coal
NG1
NG2/

NG(s) /NG1
NG2/

GTAir(s) /Air1
Air2/

Air(s) /Air1
Air2
Air3/

EXH(s) /EXG1
FG5/

FLUE(s) /FG1/


IN(u,s) /HPST1.SUPERS1
LPST1.SuperS22
HPST2.SuperS3
LPST2.SuperS42
GT1.(NG1,AIR1)
GT2.(NG2,AIR2)
HEhot.SuperS5
HEcold.DHW1
ECONOMISER1.(FW2,FG3)
EVAPORATOR1.(FW3,FG2)
SUPERHEATER1.(SATS1,FG1)
ECONOMISER2.(FW4,FG8)
EVAPORATOR2.(FW5,FG7)
SUPERHEATER2.(FG6,SATS3)
BURNER.(COAL,AIR3,EXG1)
CONDENSER.(DHW0,WETS4)/;



Scalars

a Annuity factor /0.0963/
lhvng Lower heating value of NG [MJperkg] /49.3/
ngen Efficiency of the generator /0.97/
cel Electricity price [€perMWh] /30/
IC Internal consumption of electricity [%] /10/
cng Natural gas price [€perMWh] /17/
ccoal Coal price [€perMWh] /12/
tannual Annual operation time at design load [h] /3183/;

Variables
Goal
enth(s) specific enthalpy of stream s [kJ per kg]
m(s) mass flow of stream s [kg per s]
Power(u) power output from unit u [MW]
p(s) pressure of stream s [bar]
t(s) temperature of stream s [C]
c(u) price of unit u;

Binary Variables

y binary variable for unit u;

\

  •                                    UPPER and LOWER BOUNDS
    

t.lo(s) = 10;

t.up(“DHW0”) = 70;
t.up(“DHW1”) = 100;
t.up(“DHW2”) = 150;





Equations

  •                            GENERAL CONSTRAINS
    

Objective Gain from implemented measures (€ per year)


DHwaterConstraints(DHWater) Saturated pressure for DH water;

\

  •                           E   Q   U   A   T   I   O   N   S
    


\

  •                           GENERAL CONSTRAINTS
    

Objective… GOAL =e= (cel*(1-IC/100)(sum(ST(u),ngenPower(u))+sum(GT(u),Power(u))))tannual
-(cng
(sum((u,s)$(GT(u)$IN(u,s)$fuel(s)),y(u)m(s)lhvng)))tannual
+ccoal
tannual
(enth(‘EXG1’)m(‘EXG1’)+enth(‘SuperS4’)m(‘SuperS4’))
-a
(sum(new(u),c(u)y(u)));



DHwaterConstraints(DHWater)… p(DHWater) =g= (2.71828182
(9.56756+5.39806
log((273.15+t(DHWater))/647.096)-
power(log((t(DHWater)+273.15)/647.096),2)6.16183+
1.49572
power(log((273.15+t(DHWater))/647.096),4)+
0.433*power(273.15+t(DHWater)/647.096,5)/100))-0.32;



model chp /all/;

solve chp using minlp max GOAL;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi Davor



You defined a variable “Power(u)”, so better rename that one in something else as power shouldn’t be used for naming anything in Gams.

Cheers



Renger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

Info@modelworks.ch

blog.modelworks.ch







From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Davor
Sent: Dienstag, 11. März 2014 11:27
To: gamsworld@googlegroups.com
Subject: Power function errors



Dear all,





I have troubles with Power function and I really need help. I can’t use ** operator since the base is negative and when I am trying to write for example:



power(log((t(DHWater)+273.15)/647.096),2)



I am getting errors 121, 148, 8 and so on… I can’t figure out this 121 error “Set expected” which is coming immediately after log function.



Please find relevant part of code included below.





Cheers,



Davor







Sets



u UNITS /HPST1

LPST1

HPST2

LPST2

GT1

GT2

HEhot

HEcold

ECONOMISER1

EVAPORATOR1

SUPERHEATER1

HRSG

ECONOMISER2

EVAPORATOR2

SUPERHEATER2

BURNER

CONDENSER/



new(u) /HPST1

LPST1

HPST2

LPST2

GT1

GT2

HRSG

ECONOMISER2

EVAPORATOR2

SUPERHEATER2/



ST(u) /HPST1

LPST1

HPST2

LPST2/



GT(u) /GT1

GT2/



s STREAMS /coal

NG1

NG2

Air1

Air2

Air3

EXG1

FG1

FG2

FG3

FG4

FG5

FG6

FG7

FG8

FG9

FG10

DHW0

DHW1

DHW2

SatS1

SatS3

SuperS1

SuperS2

SuperS21

SuperS22

SuperS3

SuperS4

SuperS41

SuperS42

SuperS5

WetS1

WetS2

WetS3

WetS4

FW00

FW01

FW02

FW03

FW04

FW2

FW3

FW4

FW5

FWHE1

FWHE2

FWHE21

FWHE3

FWHE31

ELECTRICITY/



FWwater(s) /FW00

FW01

FW02

FW03

FW04

FW3

FW5

FWHE1

FWHE2

FWHE21

FWHE3

FWHE31/



FWsum(s) /FW2

FW4/



DHwater(s) /DHW0

DHW1

DHW2/



fuel(s) /coal

NG1

NG2/



NG(s) /NG1

NG2/



GTAir(s) /Air1

Air2/



Air(s) /Air1

Air2

Air3/



EXH(s) /EXG1

FG5/



FLUE(s) /FG1/





IN(u,s) /HPST1.SUPERS1

LPST1.SuperS22

HPST2.SuperS3

LPST2.SuperS42

GT1.(NG1,AIR1)

GT2.(NG2,AIR2)

HEhot.SuperS5

HEcold.DHW1

ECONOMISER1.(FW2,FG3)

EVAPORATOR1.(FW3,FG2)

SUPERHEATER1.(SATS1,FG1)

ECONOMISER2.(FW4,FG8)

EVAPORATOR2.(FW5,FG7)

SUPERHEATER2.(FG6,SATS3)

BURNER.(COAL,AIR3,EXG1)

CONDENSER.(DHW0,WETS4)/;







Scalars



a Annuity factor /0.0963/

lhvng Lower heating value of NG [MJperkg] /49.3/

ngen Efficiency of the generator /0.97/

cel Electricity price [€perMWh] /30/

IC Internal consumption of electricity [%] /10/

cng Natural gas price [€perMWh] /17/

ccoal Coal price [€perMWh] /12/

tannual Annual operation time at design load [h] /3183/;



Variables

Goal

enth(s) specific enthalpy of stream s [kJ per kg]

m(s) mass flow of stream s [kg per s]

Power(u) power output from unit u [MW]

p(s) pressure of stream s [bar]

t(s) temperature of stream s [C]

c(u) price of unit u;



Binary Variables



y binary variable for unit u;




\

  •                                    UPPER and LOWER BOUNDS
    




t.lo(s) = 10;



t.up(“DHW0”) = 70;

t.up(“DHW1”) = 100;

t.up(“DHW2”) = 150;











Equations


\

  •                            GENERAL CONSTRAINS
    




Objective Gain from implemented measures (€ per year)





DHwaterConstraints(DHWater) Saturated pressure for DH water;




\

  •                           E   Q   U   A   T   I   O   N   S
    





\

  •                           GENERAL CONSTRAINTS
    




Objective… GOAL =e= (cel*(1-IC/100)(sum(ST(u),ngenPower(u))+sum(GT(u),Power(u))))*tannual

-(cng*(sum((u,s)$(GT(u)$IN(u,s)$fuel(s)),y(u)*m(s)*lhvng)))*tannual

+ccoaltannual(enth(‘EXG1’)*m(‘EXG1’)+enth(‘SuperS4’)*m(‘SuperS4’))

-a*(sum(new(u),c(u)y(u)));







DHwaterConstraints(DHWater)… p(DHWater) =g= (2.71828182
*(9.56756+5.39806*log((273.15+t(DHWater))/647.096)-

power(log((t(DHWater)+273.15)/647.096),2)*6.16183+

1.49572*power(log((273.15+t(DHWater))/647.096),4)+

0.433*power(273.15+t(DHWater)/647.096,5)/100))-0.32;







model chp /all/;



solve chp using minlp max GOAL;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Dear Renger van Nieuwkoop,


I am very grateful for this help. Completely overlooked that. Thank you!!

Sincerely,

Davor


On Tuesday, March 11, 2014 1:57:51 PM UTC+1, Renger van Nieuwkoop wrote:

Hi Davor



You defined a variable “Power(u)”, so better rename that one in something else as power shouldn’t be used for naming anything in Gams.

Cheers



Renger


Modelworks

Gewerbestrasse 15

3600 Thun – Switzerland

+41 79 818 53 73

In…@modelworks.ch

blog.modelworks.ch







From: gams...@googlegroups.com [mailto:gams...@googlegroups.com] On Behalf Of Davor
Sent: Dienstag, 11. März 2014 11:27
To: gams...@googlegroups.com
Subject: Power function errors



Dear all,





I have troubles with Power function and I really need help. I can’t use ** operator since the base is negative and when I am trying to write for example:



power(log((t(DHWater)+273.15)/647.096),2)



I am getting errors 121, 148, 8 and so on… I can’t figure out this 121 error “Set expected” which is coming immediately after log function.



Please find relevant part of code included below.





Cheers,



Davor







Sets



u UNITS /HPST1

LPST1

HPST2

LPST2

GT1

GT2

HEhot

HEcold

ECONOMISER1

EVAPORATOR1

SUPERHEATER1

HRSG

ECONOMISER2

EVAPORATOR2

SUPERHEATER2

BURNER

CONDENSER/



new(u) /HPST1

LPST1

HPST2

LPST2

GT1

GT2

HRSG

ECONOMISER2

EVAPORATOR2

SUPERHEATER2/



ST(u) /HPST1

LPST1

HPST2

LPST2/



GT(u) /GT1

GT2/



s STREAMS /coal

NG1

NG2

Air1

Air2

Air3

EXG1

FG1

FG2

FG3

FG4

FG5

FG6

FG7

FG8

FG9

FG10

DHW0

DHW1

DHW2

SatS1

SatS3

SuperS1

SuperS2

SuperS21

SuperS22

SuperS3

SuperS4

SuperS41

SuperS42

SuperS5

WetS1

WetS2

WetS3

WetS4

FW00

FW01

FW02

FW03

FW04

FW2

FW3

FW4

FW5

FWHE1

FWHE2

FWHE21

FWHE3

FWHE31

ELECTRICITY/



FWwater(s) /FW00

FW01

FW02

FW03

FW04

FW3

FW5

FWHE1

FWHE2

FWHE21

FWHE3

FWHE31/



FWsum(s) /FW2

FW4/



DHwater(s) /DHW0

DHW1

DHW2/



fuel(s) /coal

NG1

NG2/



NG(s) /NG1

NG2/



GTAir(s) /Air1

Air2/



Air(s) /Air1

Air2

Air3/



EXH(s) /EXG1

FG5/



FLUE(s) /FG1/





IN(u,s) /HPST1.SUPERS1

LPST1.SuperS22

HPST2.SuperS3

LPST2.SuperS42

GT1.(NG1,AIR1)

GT2.(NG2,AIR2)

HEhot.SuperS5

HEcold.DHW1

ECONOMISER1.(FW2,FG3)

EVAPORATOR1.(FW3,FG2)

SUPERHEATER1.(SATS1,FG1)

ECONOMISER2.(FW4,FG8)

EVAPORATOR2.(FW5,FG7)

SUPERHEATER2.(FG6,SATS3)

BURNER.(COAL,AIR3,EXG1)

CONDENSER.(DHW0,WETS4)/;







Scalars



a Annuity factor /0.0963/

lhvng Lower heating value of NG [MJperkg] /49.3/

ngen Efficiency of the generator /0.97/

cel Electricity price [€perMWh] /30/

IC Internal consumption of electricity [%] /10/

cng Natural gas price [€perMWh] /17/

ccoal Coal price [€perMWh] /12/

tannual Annual operation time at design load [h] /3183/;



Variables

Goal

enth(s) specific enthalpy of stream s [kJ per kg]

m(s) mass flow of stream s [kg per s]

Power(u) power output from unit u [MW]

p(s) pressure of stream s [bar]

t(s) temperature of stream s [C]

c(u) price of unit u;



Binary Variables



y binary variable for unit u;




\

  •                                    UPPER and LOWER BOUNDS
    




t.lo(s) = 10;



t.up(“DHW0”) = 70;

t.up(“DHW1”) = 100;

t.up(“DHW2”) = 150;











Equations


\

  •                            GENERAL CONSTRAINS
    




Objective Gain from implemented measures (€ per year)





DHwaterConstraints(DHWater) Saturated pressure for DH water;




\

  •                           E   Q   U   A   T   I   O   N   S
    





\

  •                           GENERAL CONSTRAINTS
    




Objective… GOAL =e= (cel*(1-IC/100)(sum(ST(u),ngenPower(u))+sum(GT(u),Power(u))))*tannual

-(cng*(sum((u,s)$(GT(u)$IN(u,s)$fuel(s)),y(u)*m(s)*lhvng)))*tannual

+ccoaltannual(enth(‘EXG1’)*m(‘EXG1’)+enth(‘SuperS4’)*m(‘SuperS4’))

-a*(sum(new(u),c(u)y(u)));







DHwaterConstraints(DHWater)… p(DHWater) =g= (2.71828182
*(9.56756+5.39806*log((273.15+t(DHWater))/647.096)-

power(log((t(DHWater)+273.15)/647.096),2)*6.16183+

1.49572*power(log((273.15+t(DHWater))/647.096),4)+

0.433*power(273.15+t(DHWater)/647.096,5)/100))-0.32;







model chp /all/;



solve chp using minlp max GOAL;


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.