CURENT / andes

Python toolbox / library for power system transient dynamics simulation with symbolic modeling and numerical analysis šŸ”„
https://ltb.curent.org
Other
223 stars 111 forks source link

Run-time error #162

Closed YaeSakura1 closed 3 years ago

YaeSakura1 commented 3 years ago

The following error was reported after running this command ss=andes.run('kundur_vsc.xlsx')

Working directory: "C:\Users\Administrator\ANDES\ACDC" Loaded config from file "C:\Users\Administrator.andes\andes.rc" Using generated Python code. Parsing input file "kundur_vsc.xlsx"... Input file parsed in 0.1026 seconds. System internal structure set up in 0.0249 seconds. -> System connectivity check results: No islanded bus detected. A total of 1 island(s) detected. Each island has a slack bus correctly defined and enabled.

-> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt) Power flow initialized. g_update failed. Have you run andes prepare -i after updating?

UFuncTypeError Traceback (most recent call last)

in ----> 1 ss=andes.run('kundur_vsc.xlsx') ~\Anaconda3\envs\andes\lib\site-packages\andes\main.py in run(filename, input_path, verbose, mp_verbose, ncpu, pool, cli, codegen, shell, **kwargs) 578 t0, _ = elapsed() 579 if len(cases) == 1: --> 580 system = run_case(cases[0], codegen=codegen, **kwargs) 581 elif len(cases) > 1: 582 ~\Anaconda3\envs\andes\lib\site-packages\andes\main.py in run_case(case, routine, profile, convert, convert_all, add_book, codegen, remove_pycapsule, **kwargs) 389 390 if system.is_setup: --> 391 system.PFlow.run(**kwargs) 392 for r in routine: 393 system.__dict__[routine_cli[r.lower()]].run(**kwargs) ~\Anaconda3\envs\andes\lib\site-packages\andes\routines\pflow.py in run(self, **kwargs) 196 self.niter = 0 197 while True: --> 198 mis = self.nr_step() 199 logger.info('%d: |F(x)| = %.10g', self.niter, mis) 200 ~\Anaconda3\envs\andes\lib\site-packages\andes\routines\pflow.py in nr_step(self) 100 system.s_update_var(self.models) 101 system.f_update(self.models) --> 102 system.g_update(self.models) 103 system.l_update_eq(self.models) 104 system.fg_to_dae() ~\Anaconda3\envs\andes\lib\site-packages\andes\system.py in g_update(self, models) 890 except TypeError as e: 891 logger.error("g_update failed. Have you run `andes prepare -i` after updating?") --> 892 raise e 893 894 def g_islands(self): ~\Anaconda3\envs\andes\lib\site-packages\andes\system.py in g_update(self, models) 887 """ 888 try: --> 889 self.call_models('g_update', models) 890 except TypeError as e: 891 logger.error("g_update failed. Have you run `andes prepare -i` after updating?") ~\Anaconda3\envs\andes\lib\site-packages\andes\system.py in call_models(self, method, models, *args, **kwargs) 1516 ret = OrderedDict() 1517 for name, mdl in models.items(): -> 1518 ret[name] = getattr(mdl, method)(*args, **kwargs) 1519 1520 return ret ~\Anaconda3\envs\andes\lib\site-packages\andes\core\model.py in g_update(self) 1232 for i, var in enumerate(self.cache.algebs_and_ext.values()): 1233 if var.e_inplace: -> 1234 var.e += g_ret[i] 1235 else: 1236 var.e[:] = g_ret[i] UFuncTypeError: Cannot cast ufunc 'add' output from dtype('complex128') to dtype('float64') with casting rule 'same_kind'
cuihantao commented 3 years ago

Can you send or upload the case file?

Regards, Hantao Cui On Aug 26, 2021, 10:00 PM -0500, YaeSakura1 @.***>, wrote:

Assigned #162 to @cuihantao. ā€” You are receiving this because you were assigned. Reply to this email directly, view it on GitHub, or unsubscribe.

cuihantao commented 3 years ago

I was able to replicate the issue with kundur_vsc.xlsx. Working on a fix now.

cuihantao commented 3 years ago

It has been fixed in the latest develop branch in f8af14cfa288413dae9a55f4007f9e522ff0d9fc.

cuihantao commented 3 years ago

Also, the kundur_vsc.xlsx test case has been updated.

YaeSakura1 commented 3 years ago

I still report the following error:

UFuncTypeError Traceback (most recent call last) C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_23800/1409670173.py in ----> 1 ss=andes.run('kundur_vsc.xlsx')

c:\users\administrator\andes\andes\andes\main.py in run(filename, input_path, verbose, mpverbose, ncpu, pool, cli, codegen, shell, **kwargs) 578 t0, = elapsed() 579 if len(cases) == 1: --> 580 system = run_case(cases[0], codegen=codegen, **kwargs) 581 elif len(cases) > 1: 582

c:\users\administrator\andes\andes\andes\main.py in run_case(case, routine, profile, convert, convert_all, add_book, codegen, remove_pycapsule, kwargs) 389 390 if system.is_setup: --> 391 system.PFlow.run(kwargs) 392 for r in routine: 393 system.dict[routine_cli[r.lower()]].run(**kwargs)

c:\users\administrator\andes\andes\andes\routines\pflow.py in run(self, **kwargs) 196 self.niter = 0 197 while True: --> 198 mis = self.nr_step() 199 logger.info('%d: |F(x)| = %.10g', self.niter, mis) 200

c:\users\administrator\andes\andes\andes\routines\pflow.py in nr_step(self) 100 system.s_update_var(self.models) 101 system.f_update(self.models) --> 102 system.g_update(self.models) 103 system.l_update_eq(self.models) 104 system.fg_to_dae()

c:\users\administrator\andes\andes\andes\system.py in g_update(self, models) 890 except TypeError as e: 891 logger.error("g_update failed. Have you run andes prepare -i after updating?") --> 892 raise e 893 894 def g_islands(self):

c:\users\administrator\andes\andes\andes\system.py in g_update(self, models) 887 """ 888 try: --> 889 self.call_models('g_update', models) 890 except TypeError as e: 891 logger.error("g_update failed. Have you run andes prepare -i after updating?")

c:\users\administrator\andes\andes\andes\system.py in call_models(self, method, models, *args, *kwargs) 1516 ret = OrderedDict() 1517 for name, mdl in models.items(): -> 1518 ret[name] = getattr(mdl, method)(args, **kwargs) 1519 1520 return ret

c:\users\administrator\andes\andes\andes\core\model.py in g_update(self) 1232 for i, var in enumerate(self.cache.algebs_and_ext.values()): 1233 if var.e_inplace: -> 1234 var.e += g_ret[i] 1235 else: 1236 var.e[:] = g_ret[i]

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('complex128') to dtype('float64') with casting rule 'same_kind'

YaeSakura1 commented 3 years ago

Hi, Why do I get such errors: ss=andes.run('kundur_vsc.xlsx')

Storing generated pycode to "C:\Users\Administrator.andes\pycode" Dumping calls to calls.pkl is not supported with NumPy 1.2+ ANDES is still fully functional with generated Python code. Successfully generated numerical code in 2.5761 seconds. Parsing input file "kundur_vsc.xlsx"... Input file parsed in 0.6283 seconds. System internal structure set up in 0.0239 seconds. -> System connectivity check results: No islanded bus detected. A total of 1 island(s) detected. Each island has a slack bus correctly defined and enabled.

-> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt)

KeyError Traceback (most recent call last) C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_6216/1409670173.py in ----> 1 ss=andes.run('kundur_vsc.xlsx')

c:\users\administrator\andes\andes\andes\main.py in run(filename, input_path, verbose, mpverbose, ncpu, pool, cli, codegen, shell, **kwargs) 575 t0, = elapsed() 576 if len(cases) == 1: --> 577 system = run_case(cases[0], codegen=codegen, **kwargs) 578 elif len(cases) > 1: 579

c:\users\administrator\andes\andes\andes\main.py in run_case(case, routine, profile, convert, convert_all, add_book, codegen, remove_pycapsule, kwargs) 386 387 if system.is_setup: --> 388 system.PFlow.run(kwargs) 389 for r in routine: 390 system.dict[routine_cli[r.lower()]].run(**kwargs)

c:\users\administrator\andes\andes\andes\routines\pflow.py in run(self, **kwargs) 186 187 self.summary() --> 188 self.init() 189 190 if system.dae.m == 0:

c:\users\administrator\andes\andes\andes\routines\pflow.py in init(self) 74 75 self.system.set_var_arrays(self.models, inplace=True, alloc=False) ---> 76 self.system.init(self.models, routine='pflow') 77 logger.info('Power flow initialized.') 78

c:\users\administrator\andes\andes\andes\system.py in init(self, models, routine) 667 668 # initialize variables second --> 669 mdl.init(routine=routine) 670 671 self.vars_to_dae(mdl)

c:\users\administrator\andes\andes\andes\core\model.py in init(self, routine) 1651 1652 # evaluate ConstService and VarService -> 1653 self.s_update() 1654 1655 # find out if variables need to be initialized for routine

c:\users\administrator\andes\andes\andes\core\model.py in s_update(self) 1047 1048 # Block-level s_numeric not supported. -> 1049 self.get_inputs(refresh=True) 1050 1051 def s_update_var(self):

c:\users\administrator\andes\andes\andes\core\model.py in get_inputs(self, refresh) 904 if len(self._input) == 0 or refresh: 905 self.refresh_inputs() --> 906 self.refresh_inputs_arg() 907 908 return self._input

c:\users\administrator\andes\andes\andes\core\model.py in refresh_inputs_arg(self) 976 977 for key, val in mapping.items(): --> 978 source = self.calls.dict[key] 979 for name in source: 980 val[name] = [self._input[arg] for arg in source[name]]

KeyError: 'ia_args'

cuihantao commented 3 years ago

You will need to run andes prepare after updating.

Regards, Hantao Cui On Aug 28, 2021, 2:14 AM -0500, YaeSakura1 @.***>, wrote:

Hi, Why do I get such errors: ss=andes.run('kundur_vsc.xlsx') Storing generated pycode to "C:\Users\Administrator.andes\pycode" Dumping calls to calls.pkl is not supported with NumPy 1.2+ ANDES is still fully functional with generated Python code. Successfully generated numerical code in 2.5761 seconds. Parsing input file "kundur_vsc.xlsx"... Input file parsed in 0.6283 seconds. System internal structure set up in 0.0239 seconds. -> System connectivity check results: No islanded bus detected. A total of 1 island(s) detected. Each island has a slack bus correctly defined and enabled. -> Power flow calculation Sparse solver: KLU Solution method: NR method Sparse addition: Fast in-place (kvxopt) KeyError Traceback (most recent call last) C:\Users\ADMINI~1\AppData\Local\Temp/ipykernel_6216/1409670173.py in ----> 1 ss=andes.run('kundur_vsc.xlsx') c:\users\administrator\andes\andes\andes\main.py in run(filename, input_path, verbose, mpverbose, ncpu, pool, cli, codegen, shell, **kwargs) 575 t0, = elapsed() 576 if len(cases) == 1: --> 577 system = run_case(cases[0], codegen=codegen, kwargs) 578 elif len(cases) > 1: 579 c:\users\administrator\andes\andes\andes\main.py in run_case(case, routine, profile, convert, convert_all, add_book, codegen, remove_pycapsule, kwargs) 386 387 if system.is_setup: --> 388 system.PFlow.run(kwargs) 389 for r in routine: 390 system.dict[routine_cli[r.lower()]].run(kwargs) c:\users\administrator\andes\andes\andes\routines\pflow.py in run(self, **kwargs) 186 187 self.summary() --> 188 self.init() 189 190 if system.dae.m == 0: c:\users\administrator\andes\andes\andes\routines\pflow.py in init(self) 74 75 self.system.set_var_arrays(self.models, inplace=True, alloc=False) ---> 76 self.system.init(self.models, routine='pflow') 77 logger.info('Power flow initialized.') 78 c:\users\administrator\andes\andes\andes\system.py in init(self, models, routine) 667 668 # initialize variables second --> 669 mdl.init(routine=routine) 670 671 self.vars_to_dae(mdl) c:\users\administrator\andes\andes\andes\core\model.py in init(self, routine) 1651 1652 # evaluate ConstService and VarService -> 1653 self.s_update() 1654 1655 # find out if variables need to be initialized for routine c:\users\administrator\andes\andes\andes\core\model.py in s_update(self) 1047 1048 # Block-level s_numeric not supported. -> 1049 self.get_inputs(refresh=True) 1050 1051 def s_update_var(self): c:\users\administrator\andes\andes\andes\core\model.py in get_inputs(self, refresh) 904 if len(self._input) == 0 or refresh: 905 self.refresh_inputs() --> 906 self.refresh_inputs_arg() 907 908 return self._input c:\users\administrator\andes\andes\andes\core\model.py in refresh_inputs_arg(self) 976 977 for key, val in mapping.items(): --> 978 source = self.calls.dict[key] 979 for name in source: 980 val[name] = [self._input[arg] for arg in source[name]] KeyError: 'ia_args' ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

YaeSakura1 commented 3 years ago

Thank you!! I solved the problem. Than , when i run the command : ss.TDS.run() I got the following problem:

I'm using jupyter lab ; python version is 3.9

-> Time Domain Simulation Summary: Sparse Solver: KLU Simulation time: 0-20.0 s. Fixed step size: h=33.33 ms. Shrink if not converged. C:\Users\Administrator.andes\pycode\EXDC2.py:75: RuntimeWarning: invalid value encountered in true_divide return (sqrt(SAT_E1SAT_SE1/(SAT_E2SAT_SE2))*((greater(SAT_SE2, 0)) + (less(SAT_SE2, 0)))) Suspect initialization issue! Simulation may crash!

Name | Var. Value | Eqn. Mismatch -----+------------+--------------

Initialization for dynamics failed in 0.0628 seconds. 0%| | 0/100 [00:00<?, ?%/s] NaN found in solution. Convergence is not likely Simulation terminated at t=0.0000 s. Simulation completed in 0.0089 seconds. TimeSeries does not contain any time stamp. Outputs to "kundur_vsc_out.lst" and "kundur_vsc_out.npz". Outputs written in 0.0019 seconds.

False

cuihantao commented 3 years ago

Please use the latest version of kundur_vsc.xlsx from the development branch.

Regards, Hantao Cui On Aug 28, 2021, 8:56 AM -0500, YaeSakura1 @.***>, wrote:

Thank you!! I solved the problem. Than , when i run the command : ss.TDS.run() I got the following problem: I'm using jupyter lab ; python version is 3.9 -> Time Domain Simulation Summary: Sparse Solver: KLU Simulation time: 0-20.0 s. Fixed step size: h=33.33 ms. Shrink if not converged. C:\Users\Administrator.andes\pycode\EXDC2.py:75: RuntimeWarning: invalid value encountered in true_divide return (sqrt(SAT_E1SAT_SE1/(SAT_E2SAT_SE2))*((greater(SAT_SE2, 0)) + (less(SAT_SE2, 0)))) Suspect initialization issue! Simulation may crash! Name | Var. Value | Eqn. Mismatch -----+------------+-------------- Initialization for dynamics failed in 0.0628 seconds. 0%| | 0/100 [00:00<?, ?%/s] NaN found in solution. Convergence is not likely Simulation terminated at t=0.0000 s. Simulation completed in 0.0089 seconds. TimeSeries does not contain any time stamp. Outputs to "kundur_vsc_out.lst" and "kundur_vsc_out.npz". Outputs written in 0.0019 seconds. False ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

YaeSakura1 commented 3 years ago

Thank you, I need to clone the code under develop branch, right?

cuihantao commented 3 years ago

You can stash your changes and checkout the development. Feel free to find git tutorials online.

Regards, Hantao Cui On Aug 28, 2021, 9:02 AM -0500, YaeSakura1 @.***>, wrote:

Thank you, I need to clone the code under develop branch, right? ā€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.