Skip to content

MultiPhaseTPFlash throws ArgumentError: reducing over an empty collection is not allowed #478

@abcdvvvv

Description

@abcdvvvv

Summary

A call to MultiPhaseTPFlash aborts with the error above. It appears during the TP flash when assembling/aggregating phase results (likely a reduce/maximum/sum over an empty collection). Please help confirm the root cause and the correct fix.

Minimal Reproducible Example

# The mixture model is as reported in #454.
p = 2.99e6
t = 450.74
n = [3.68, 7.069, 2.3402, 0.8063]
res = Clapeyron.tp_flash2(mix, p, t, n, MultiPhaseTPFlash(full_tpd=true))

Output:

ERROR: ArgumentError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] _empty_reduce_error()
    @ Base .\reduce.jl:311
  [2] mapreduce_empty(f::Function, op::Function, T::Type)
    @ Base .\reduce.jl:313
  [3] reduce_empty(op::Base.MappingRF{typeof(eltype), typeof(promote_type)}, ::Type{Vector{Float64}})
    @ Base .\reduce.jl:350
  [4] reduce_empty_iter
    @ .\reduce.jl:373 [inlined]
  [5] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Vector{Float64}}, ItrEltype::Base.HasEltype)
    @ Base .\reduce.jl:369
  [6] _mapreduce
    @ .\reduce.jl:421 [inlined]
  [7] _mapreduce_dim
    @ .\reducedim.jl:334 [inlined]
  [8] mapreduce
    @ .\reducedim.jl:326 [inlined]
  [9] reduce
    @ .\abstractarray.jl:1775 [inlined]
 [10] initial_beta!(comps::Vector{Vector{Float64}}, z::Vector{Float64})    
    @ Clapeyron Clapeyron.jl\src\methods\property_solvers\multicomponent\tp_flash\multiphase.jl:1163
 [11] tp_flash_multi(model::PR{…}, p::Float64, T::Float64, nn::Vector{…}, options::MultiPhaseTPFlash{…})
    @ Clapeyron Clapeyron.jl\src\methods\property_solvers\multicomponent\tp_flash\multiphase.jl:224
 [12] tp_flash_impl
    @ Clapeyron.jl\src\methods\property_solvers\multicomponent\tp_flash\multiphase.jl:178 [inlined]
 [13] tp_flash2(model::PR{…}, p::Float64, T::Float64, n::Vector{…}, method::MultiPhaseTPFlash{…})
    @ Clapeyron Clapeyron.jl\src\methods\property_solvers\multicomponent\flash\PT.jl:86

Thank you for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions