Skip to content

Commit

Permalink
temporal fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fedebenelli committed Feb 7, 2024
1 parent a421c51 commit 0d23e83
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 24 deletions.
3 changes: 2 additions & 1 deletion app/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ subroutine pt_envelopes
select case(pt_case)
case("0")
isolated: block
use legacy_ar_models, only: nc, termo, z
use legacy_ar_models, only: nc, z
use legacy_thermo_properties, only: termo
use envelopes, only: pt_envelope_three_phase
real(pr) :: p, v, t
real(pr) :: lnphix(nc), lnphiy(nc), &
Expand Down
4 changes: 2 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ library = false
stdlib = "*"
# minpack= "*"
ftools = { git = "https://github.com/fedebenelli/ftools" }
yaeos = { git = "https://github.com/fedebenelli/yaeos" }
yaeos = { git = "https://github.com/ipqa-research/yaeos" }
FLAP = { git = "https://github.com/szaghi/FLAP", tag="v1.2.5" }
fordiff = {git="https://github.com/gha3mi/fordiff.git"}
forsolver = { git="https://github.com/gha3mi/forsolver.git" }
progress-bar = { git="https://github.com/zoziha/progress-bar" }
# progress-bar = { git="https://github.com/zoziha/progress-bar" }

[fortran]
implicit-external = false # default: false
Expand Down
15 changes: 9 additions & 6 deletions src/new/envelopes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module envelopes
use constants, only: pr
use linalg, only: solve_system, full_newton
use dtypes, only: AbsEnvel, envelope, critical_point
use legacy_ar_models, only: nc, termo
use progress_bar_module, only: progress_bar
use legacy_ar_models, only: nc
use legacy_thermo_properties, only: termo
! use progress_bar_module, only: progress_bar
implicit none

type, extends(AbsEnvel) :: PTEnvel3
Expand Down Expand Up @@ -257,7 +258,8 @@ subroutine fix_delx(&

subroutine find_hpl(t, p, k)
!! Find a HPLL initial point at a given pressure
use legacy_ar_models, only: nc, termo, z
use legacy_ar_models, only: nc, z
use legacy_thermo_properties, only: termo
real(pr), intent(in out) :: t
real(pr), intent(in) :: p
real(pr), intent(out) :: k(nc)
Expand Down Expand Up @@ -693,7 +695,8 @@ subroutine pt_F_three_phases(Xvars, ns, S, F, dF)
!! \sum_{i=1}^N (x_i - y_i),
!! X_{ns} - S
!! ] \)
use legacy_ar_models, only: TERMO, z
use legacy_ar_models, only: z
use legacy_thermo_properties, only: termo
use iso_fortran_env, only: error_unit
real(pr), intent(in) :: Xvars(:) !! Vector of variables
integer, intent(in) :: ns !! Number of specification
Expand Down Expand Up @@ -868,7 +871,7 @@ subroutine pt_envelope_three_phase(X0, spec_number, del_S0, envel)
! ======================================================================

enveloop: do point = 1, max_points
call progress_bar(point, max_points, advance=.false.)
! call progress_bar(point, max_points, advance=.false.)
call full_newton(pt_F_three_phases, iters, X, ns, S, max_iters, F, dF, solvetol=1e-7_pr)
if (iters >= max_iters) then
print *, "Breaking: Above max iterations"
Expand Down Expand Up @@ -983,7 +986,7 @@ subroutine pt_envelope_three_phase(X0, spec_number, del_S0, envel)
end if

close (funit_output)
call progress_bar(point, max_points, .true.)
! call progress_bar(point, max_points, .true.)
envel%lnKx = XS(:point, :n)
envel%lnKy = XS(:point, n+1:2*n)
envel%P = exp(XS(:point, 2*n + 1))
Expand Down
2 changes: 2 additions & 0 deletions src/new/io_nml.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module io_nml
implicit none
integer :: nunit_input



character(len=50) :: model, mixrule
character(len=254) :: path_to_file
character(len=50) :: spec
Expand Down
10 changes: 5 additions & 5 deletions src/new/mod_dsp_lines.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module dsp_lines
use inj_envelopes, only: update_spec, injection_case, z_0, z_injection, &
get_z, injelope
use linalg, only: solve_system, interpol, full_newton
use progress_bar_module, only: progress_bar
! use progress_bar_module, only: progress_bar

implicit none
! ===========================================================================
Expand Down Expand Up @@ -40,7 +40,7 @@ subroutine dsp_line_F(Xvars, ns, S, F, dF)
!! \sum_{i=1}^N (y_i - z_i),
!! X_{ns} - S
!! ] \)
use legacy_ar_models, only: TERMO
use legacy_thermo_properties, only: TERMO
use iso_fortran_env, only: error_unit
real(pr), intent(in) :: Xvars(:) !! Vector of variables
integer, intent(in) :: ns !! Number of specification
Expand Down Expand Up @@ -190,10 +190,10 @@ subroutine dsp_line(X0, spec_number, del_S0, envels)
! ======================================================================

enveloop: do point = 1, max_points
call progress_bar(point, max_points, advance=.false.)
! call progress_bar(point, max_points, advance=.false.)
call full_newton(dsp_line_F, iters, X, ns, S, max_iters, F, dF)
if (iters >= max_iters) then
call progress_bar(point, max_points, advance=.true.)
! call progress_bar(point, max_points, advance=.true.)
print *, "Breaking: Above max iterations"
exit enveloop
end if
Expand All @@ -209,7 +209,7 @@ subroutine dsp_line(X0, spec_number, del_S0, envels)
S = X(ns)

if (any(break_conditions_dsp_line(X, ns, S, del_S)) .and. point > 10) then
call progress_bar(point, max_points, .true.)
! call progress_bar(point, max_points, .true.)
print *, "Breaking: ", break_conditions_dsp_line(X, ns, S, del_S)
exit enveloop
end if
Expand Down
21 changes: 11 additions & 10 deletions src/new/mod_inj_envelopes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module inj_envelopes
use constants, only: pr, R
use dtypes, only: envelope, critical_point
use linalg, only: solve_system, interpol, full_newton
use progress_bar_module, only: progress_bar
!use progress_bar_module, only: progress_bar

implicit none

Expand Down Expand Up @@ -74,7 +74,7 @@ subroutine F_injection(X, ns, S, F, dF)
!! - Addition: \( z = \frac{\alpha z_i + (1-\alpha) z_0}{\sum_{i=1}^N \alpha z_i + (1-\alpha) z_0} \)
!!
use iso_fortran_env, only: error_unit
use legacy_ar_models, only: TERMO
use legacy_thermo_properties, only: TERMO
real(pr), intent(in) :: X(:) !! Vector of variables
integer, intent(in) :: ns !! Number of specification
real(pr), intent(in) :: S !! Specification value
Expand Down Expand Up @@ -193,13 +193,13 @@ subroutine injection_envelope(X0, spec_number, del_S0, envels)
! ========================================================================

enveloop: do point = 1, max_points
call progress_bar(point, max_points, advance=.false.)
! call progress_bar(point, max_points, advance=.false.)
call full_newton(&
f_injection, iters, X, ns, S, max_iters, F, dF, solvetol=solve_tol &
)

if (iters >= max_iters) then
call progress_bar(point, max_points, advance=.true.)
! call progress_bar(point, max_points, advance=.true.)
print *, "Breaking: Above max iterations"
exit enveloop
end if
Expand Down Expand Up @@ -387,7 +387,7 @@ subroutine F_injection_three_phases(Xvars, ns, S, F, dF)
!! \sum_{i=1}^N (x_i - y_i),
!! X_{ns} - S
!! ] \)
use legacy_ar_models, only: TERMO
use legacy_thermo_properties, only: TERMO
use iso_fortran_env, only: error_unit
real(pr), intent(in) :: Xvars(:) !! Vector of variables
integer, intent(in) :: ns !! Number of specification
Expand Down Expand Up @@ -587,12 +587,12 @@ subroutine injection_envelope_three_phase(X0, spec_number, del_S0, envels)
! ======================================================================

enveloop: do point = 1, max_points
call progress_bar(point, max_points, advance=.false.)
! call progress_bar(point, max_points, advance=.false.)
call full_newton(&
F_injection_three_phases, iters, X, ns, S, max_iters, F, dF, solvetol=solve_tol &
)
if (iters >= max_iters) then
call progress_bar(point, max_points, advance=.true.)
! call progress_bar(point, max_points, advance=.true.)
print *, "Breaking: Above max iterations"
exit enveloop
end if
Expand Down Expand Up @@ -674,15 +674,15 @@ subroutine injection_envelope_three_phase(X0, spec_number, del_S0, envels)
end block detect_critical

if (x(2*n + 3) > 1 .or. (x(2*n+3) < 0)) then
call progress_bar(point, max_points, .true.)
! call progress_bar(point, max_points, .true.)
print *, "Breaking: positive 𝜷"
exit enveloop
end if

X = X + dXdS*del_S
S = X(ns)
if (any(break_conditions_three_phases(X, ns, S, del_S)) .and. point > 10) then
call progress_bar(point, max_points, .true.)
! call progress_bar(point, max_points, .true.)
print *, "Breaking: ", break_conditions_three_phases(X, ns, S, del_S)
exit enveloop
end if
Expand Down Expand Up @@ -983,7 +983,8 @@ function px_three_phase_from_inter(&

function px_hpl_line(alpha_0, p)
! Find a HPLL PX line at a given pressure, starting from a given alpha
use legacy_ar_models, only: nc, termo
use legacy_ar_models, only: nc
use legacy_thermo_properties, only: termo
use linalg, only: solve_system
real(pr), intent(in) :: alpha_0 !! Staring \(\alpha\) to search
real(pr), intent(in) :: p !! Pressure of HPLL
Expand Down

0 comments on commit 0d23e83

Please sign in to comment.