gmlc-dispatches / dispatches

Primary repository for distributed dispatches software tools
https://dispatches.readthedocs.io/
Other
12 stars 34 forks source link

Multiple tests failing with ZeroDivisionError: float division by zero #204

Closed adam-a-a closed 1 year ago

adam-a-a commented 1 year ago

I ran pytest after pulling from main and got back several errors. I'm posting the issue to either bring awareness to the errors or confirm that is a known issue and someone is working on tackling this:

================================================================================ short test summary info ================================================================================ 
FAILED dispatches/case_studies/fossil_case/supercritical_plant/tests/test_scpc_flowsheet.py::test_scpc_without_tes - ZeroDivisionError: float division by zero
FAILED dispatches/case_studies/fossil_case/supercritical_plant/tests/test_scpc_flowsheet.py::test_scpc_with_tes - ZeroDivisionError: float division by zero
FAILED dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_charge_usc_powerplant.py::test_main_function - ZeroDivisionError: float division by zero
FAILED dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py::test_main_function - ZeroDivisionError: float division by zero       
FAILED dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_integrated_storage_with_ultrasupercritical_power_plant.py::test_main_function - ZeroDivisionError:
 float division by zero
FAILED dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py::test_main_function - ZeroDivisionError: float division by zero
FAILED dispatches/tests/test_headers.py::test_headers - AssertionError: assert 1 == 0
FAILED dispatches/unit_models/tests/test_concrete_tes.py::test_tes_inputs - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_charge_usc_powerplant.py::test_initialize - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_charge_usc_powerplant.py::test_costing - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_charge_usc_powerplant.py::test_usc_charge_model - ZeroDivisionError: float division by zero        
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py::test_initialize - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py::test_costing - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_discharge_usc_powerplant.py::test_usc_discharge_model - ZeroDivisionError: float division by zero  
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_integrated_storage_with_ultrasupercritical_power_plant.py::test_build - ZeroDivisionError: float di
vision by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_integrated_storage_with_ultrasupercritical_power_plant.py::test_initialization - ZeroDivisionError:
 float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_integrated_storage_with_ultrasupercritical_power_plant.py::test_costing_method - ZeroDivisionError:
 float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_multiperiod_integrated_storage_usc.py::test_usc_model - ZeroDivisionError: float division by zero  
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_multiperiod_integrated_storage_usc.py::test_unfix_dof - ZeroDivisionError: float division by zero  
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/storage/tests/test_multiperiod_integrated_storage_usc.py::test_custom_initialization - ZeroDivisionError: float divisi
on by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py::test_initialize - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py::test_unit_consistency - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py::test_usc_model - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py::test_change_power - ZeroDivisionError: float division by zero
ERROR dispatches/case_studies/fossil_case/ultra_supercritical_plant/tests/test_usc_powerplant.py::test_change_pressure - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_concrete_tes.py::test_tes_charge - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_concrete_tes.py::test_tes_discharge - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_concrete_tes.py::test_tes_charge_discharge - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_concrete_tes.py::test_tes_combined - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_heat_exchanger_tube.py::TestConcreteTube::test_build - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_heat_exchanger_tube.py::TestConcreteTube::test_initialize - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_heat_exchanger_tube.py::TestConcreteTube::test_solve - ZeroDivisionError: float division by zero
ERROR dispatches/unit_models/tests/test_heat_exchanger_tube.py::TestConcreteTube::test_conservation - ZeroDivisionError: float division by zero
====================================================== 8 failed, 96 passed, 1 skipped, 2 warnings, 25 errors in 391.93s (0:06:31) =============================================
lbianchi-lbl commented 1 year ago

Thanks for bringing this up @adam-a-a. Can you provide the following information, if available:

adam-a-a commented 1 year ago

Thanks for bringing this up @adam-a-a. Can you provide the following information, if available:

  • Exact pytest command used
  • A larger portion of the pytest output, containing the stack trace (for at least one of the 25 errors)
  • The output of the following commands run in the same environment

    • python -c "import sys; print(sys.executable)"
    • pip list
    • pip show pyomo idaes-pse dispatches

@lbianchi-lbl - I'm not up-to-speed on which versions of IDAES and Pyomo I should have installed in my environment and probably should just reinstall or update after this, but here are my responses to your inquiries:

  1. I just ran pytest on the whole repo.
  2. Example test output for one of the errors:
    ----------------------------------------------------------------------------------- Captured log call ----------------------------------------------------------------------------------- 
    ERROR    pyomo.core:helmholtz_functions.py:1961 evaluating object as numeric value: fs.props_water.dens_mass_star/fs.props_water.mw
    (object: <class 'pyomo.core.expr.numeric_expr.NPV_DivisionExpression'>)
    float division by zero
    ERROR    idaes.core.base.process_block:process_block.py:41 Failure in build: fs.props_water
    Traceback (most recent call last):
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\idaes\core\base\process_block.py", line 39, in _rule_default
    b.build()
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\idaes\models\properties\general_helmholtz\helmholtz_functions.py", line 1756, in build
    self.add_param(
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\idaes\models\properties\general_helmholtz\helmholtz_functions.py", line 1961, in add_param
    initialize=pyo.value(expr),
    File "pyomo\core\expr\numvalue.pyx", line 153, in pyomo.core.expr.numvalue.value
    File "pyomo\core\expr\numvalue.pyx", line 138, in pyomo.core.expr.numvalue.value
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\pyomo\core\expr\base.py", line 115, in __call__
    return evaluate_expression(self, exception)
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\pyomo\core\expr\visitor.py", line 1242, in evaluate_expression
    ans = visitor.dfs_postorder_stack(exp)
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\pyomo\core\expr\visitor.py", line 897, in dfs_postorder_stack
    ans = self.visit(_obj, _result)
    File "C:\Users\adama\Anaconda3\envs\dispatches\lib\site-packages\pyomo\core\expr\visitor.py", line 1129, in visit
    return node._apply_operation(values)
    File "pyomo\core\expr\numeric_expr.pyx", line 552, in pyomo.core.expr.numeric_expr.DivisionExpression._apply_operation
    ZeroDivisionError: float division by zero
  3. Output from commands:
lbianchi-lbl commented 1 year ago

One things that jumps to the eye is the Pyomo version - I've just tried installing locally from the current main and I get 6.5.0, although this might depend on whether #203 had been merged or not at the time of your original attempt.

Can you try repeating the test, preferably in a fresh environment, using the current main (03b936a7c0999c2e91f542094557c708532ba7e6)?

lbianchi-lbl commented 1 year ago

Closing this as we haven't been able to reproduce the errors. If this keeps happening to @adam-a-a or others, please feel free to reopen this or create a new issue.