Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avi/initial plus sp1 general #26

Merged
merged 13 commits into from
Dec 3, 2022
Merged

Conversation

avinashresearch1
Copy link
Owner

Completed:

  • Most required type and problem definitions. Types for different kinds of streams.
  • Features for solving a ClassicHENSProblem- the most common kind of problem with fixed stream data
  • Features for importing XLSX file data
  • Generating temperature intervals. Plotting composite curves.
  • Solving the minimum utilities subproblem

Kwonly = "18d08c8c-0732-55ee-a446-91a51d7b4206"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"

[compat]
julia = "1.6"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure you wanna go with Julia 1.6? Is that necessary?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update at a later stage. Would rather be conservative on this.

hot_utilities_dict::Dict{String, SimpleHotUtility}
cold_utilities_dict::Dict{String, SimpleColdUtility}
ΔT_min::Float64
@add_kwonly function ClassicHENSProblem(hot_streams_dict, cold_streams_dict, hot_utilities_dict = Dict{String, SimpleHotUtility}(), cold_utilities_dict = Dict{String, SimpleColdUtility}(); ΔT_min = 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have a good reason to make this an inner constructor? Usually inner constructors are used if you want to force some sort of sanity check that cannot be sidestepped. doesn't seem to be the case here. In that case it just reduces the extensibility but adds no value otherwise. Not sure if really critical here, though.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Difficult choice. I am inclined to keep the inner constructor as I may need to have these sanity checks as this constructor directly parses user information. Also, in the worst case if I find it hinders extensibility, its easier to delete than add it.


Holds the classical HENS problem with fixed stream data.
"""
mutable struct ClassicHENSProblem <: AbstractSynthesisProblem
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be mutable? Since it holds the dictionaries already it feels like there is little value? Perhaps one wants to adjust $\Delta T_{min}$ after the fact?

Copy link
Owner Author

@avinashresearch1 avinashresearch1 Dec 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, made it immutable


Single hot stream
"""
mutable struct HotStream <: AbstractStream
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the mutability of this I like. I could see adjusting stream data to be an important use case even after the problem has been defined.

"""
mutable struct HotStream <: AbstractStream
name::String # May eventually need parametric types when these can be variables.
T_in::Float64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to restrict to Float64? What if someone uses Float32 for whatever reason or inputs integer data for temperatures. Maybe make the type parametric, and handle promotion to the same number type for all inputs?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point to use parametric types. #28

I do accept any type in the constructor and promote to Float64 as seen in the constructor code.

Supports multiple utilities if appropriately matched to interval.
[TODO: Utility costs]
"""
function solve_minimum_utilities_subproblem(prob::ClassicHENSProblem; time_limit = 60.0, presolve = true, optimizer = HiGHS.Optimizer, verbose = true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of macros to create the problem is very slow. Avoiding that is a lot of work and takes a lot of learning about JuMP (or ideally MathOptInterface) though. Depending on how big the problems become, the inefficiency of macro usage can actually become very noticeable (especially when you start thinking about the nonlinear problems). For now I think this is fine but something to keep in mind.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will make an issue #27

hot_utilities_contribs::Dict{String, Float64}
"""Cold utility entering system at interval. Note: Each CU can only enter at one interval"""
cold_utilities_contribs::Dict{String, Float64}
@add_kwonly function TemperatureInterval(index, T_hot_upper, T_hot_lower, T_cold_upper, T_cold_lower, R_in = 0.0, R_out = 0.0, hot_streams_contribs = Dict{String, Float64}(), cold_streams_contribs = Dict{String, Float64}(), hot_utilities_contribs = Dict{String, Float64}(), cold_utilities_contribs = Dict{String, Float64}())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inner constructor concern again.

src/TemperatureIntervals/temperature_intervals.jl Outdated Show resolved Hide resolved
Generates the intervals necessary for the heat cascade diagram. Currently only works with one hot and one cold utility.
TODO: Multiple utilities.
"""
function generate_heat_cascade_intervals(prob::ClassicHENSProblem)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this somehow all feels unbelievably convoluted and unnecessarily complicated. But since this also seems to be only some ancillary functionality this is fine.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to make the JuMP Model()/optimization problem that defines variables on a set of intervals print nicely. Otherwise, it prints all fields and can be overwhelming/not easy to debug.


Plots the cold-side composite curve. Assume intervals are already sorted e.g., attained from the `generate_heat_cascade_intervals` function.
"""
function plot_cold_composite_curve(sorted_intervals::Vector{TemperatureInterval}; ref_enthalpy = 0.0, ylabel = "T [°C or K]", xlabel = "Heat duty Q", verbose = false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could think about adding a plot recipe that adds a method to plot itself. Perhaps that is more convenient than typing this whole thing.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will add a recipe for a plot for the ClassicHENSProblem type, then perhaps move these to internal functionaility. TBD.

@avinashresearch1 avinashresearch1 merged commit 8a07c5a into main Dec 3, 2022
@avinashresearch1 avinashresearch1 deleted the avi/initial_plus_sp1_general branch December 3, 2022 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants