0

Checking whether the voltage within the range

My Goal:Checking whether the voltage within the range of 0.9 to 1.05

**My_Code_1:**

ierr, volts = psspy.abusreal(1,1,string='PU')

x1.set_cell ((3, 'z'),'pass' if (0.9 < max(zip(*volts )) < 1.05  and  0.9 < min(zip(*volts ))

             < 1.05) else 'Not Pass')*


**My_Code_1_Result:**  

'Not Pass'

**My_Code_2:**

ierr, volts = psspy.abusreal(1,1,string='PU')

max_value = max(zip(*volts ))

min_value = min(zip(*volts ))

x1.set_cell ((3, 'z'),'pass' if (0.9 < max_value  < 1.05  and  0.9 < min_value< 1.05) else 

             'Not Pass')*


**My_Code_2_Result:**  

'Not Pass'

**My_Code_3:**

tolerance = 1e-6 

ierr, volts = psspy.abusreal(1,1,string='PU')

x1.set_cell ((3, 'z'),'pass' if (0.9+tolerance < max(zip(*volts )) < 1.05-tolerance and 0.9+tolerance < min(zip(*volts)<1.05-tolerance) else 'Not Pass')*


**My_Code_3_Result:**  

'Not Pass'

I checked all the value of max(zip(volts )) and min(zip(volts )).

They are all within 0.9~1.05. But why keep jumping into else shows 'Not Pass' ?

I did it wrong or can't do like this ?

Thank you for reading my question.

Jimmy's avatar
13
Jimmy
asked 2023-08-09 03:59:10 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

The problem is that max(zip(*volts)) returns a tuple, e.g. (1.0404236316680908,) and not a float, so the if-statement doesn't work.

Use max(volts[0]) instead.

A tip is to print the values to check if they have the expected format when the code is not working correctly.

perolofl's avatar
3.8k
perolofl
answered 2023-08-09 07:03:49 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank you for answering my questions. I see. Thank you.

Jimmy's avatar Jimmy (2023-08-10 00:16:25 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer