# How to obtain and hold the value of STATE/VAR at a certain time?

In WECC model 'REECAU1', it shows that if voltage_dp=1, STATE(K+2) and STATE(K+3) will be frozen and the value of Iqcmd will be changed from STATE(K+3) to (STATE(K+3)+Iqv) for Thld seconds. I wonder how to achieve this in FORTRAN?

It seems that CALL DSRVAL in API call get the certain time. However, how can I get the value of STATE at that time? IF I use VAR(L) to store the value, it would be changed over time since VAR(L) is a variable array.

As for set some value for seconds, I think it could be

IF(A＜TIME＜A+Thld) Iqcmd=STATE(K+3)+Iqv

Is it correct?

edit retag close merge delete

Sort by » oldest newest most voted

just set dstate=0, and the relative state value will be frozen, so can hold the value for any more time u want

more

dat don't want to freeze the state, just preseve the state value at a certain time in a var.

( 2023-09-26 09:25:42 -0500 )edit

Do you want to write your own user moderl version of REECAU1?

The simulation time is already available in variable TIME, so there is no need for DSRVAL.

At each time step the value of the STATE is in the STATE array. I don't understand the question.

more

REECAU1 is just an example. I'm trying to write a LVRT model. My question is: 1.As the value of STATE is stored at each time step, how could I return it? If I want to get the value of STATE(3) at 1 second, what should I write in FORTRAN?

( 2022-11-24 18:41:59 -0500 )edit

2.If I want to know when is the ETERM of a machine less than 0.2 for the first time, what should I write in FORTRAN? By writing ‘IF(ETERM>0.2) CALL DSRVAL(TIME,RVAL,IERR)’ , I can get TIME when ETERM=0.2. But if ETERM rises to 0.2, RVAL would update agin.

( 2022-11-24 18:49:55 -0500 )edit

Why are you using DSRVAL to get the time? It is already available in common variable TIME.

( 2022-11-25 00:59:54 -0500 )edit

Yes, you are right. I realize that ‘IF(ETERM>0.2) VAR(L)=TIME)’ works too. But it would be changed as well when ETERM rises to 0.2, since VAR(L) will be updated in MODE2/3. How could I store and hold TIME?

( 2022-11-25 01:11:05 -0500 )edit

In other posts, I saw that one could get the value of varibles at TIME-DELT. I don't find the way to achieve this.

( 2022-11-25 01:16:08 -0500 )edit