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

Solving ifort/IFX runtime issues #101

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- {compiler: gcc, version: 11}
- {compiler: gcc, version: 12}
- {compiler: gcc, version: 13}
- {compiler: intel, version: '2024.2'}
- {compiler: intel, version: '2024.1'}
- {compiler: intel, version: '2023.2'}
steps:
Expand Down
6 changes: 4 additions & 2 deletions src/equilibria/rachford_rice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ subroutine betato01(z, K)
real(pr), intent(in) :: z(:) !! Molar fractions of the system
real(pr) :: K(:) !! K factors \(\frac{y_i}{x_i}\)

real(pr) :: g0, g1 ! function g valuated at beta=0 and 1, based on K factors
real(pr) :: g0 !! function g valuated at beta=0
real(pr) :: g1 !! function g valuated and 1

g1 = 1.0
g0 = sum(z*K) - 1._pr
g1 = 1._pr - sum(z/K)
do while (g0 < 0 .or. g1 > 0)
if (any(isnan([g0, g1])) .or. all(K==0)) exit
g0 = sum(z*K) - 1._pr
Expand Down
21 changes: 16 additions & 5 deletions src/equilibria/stability.f90
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ module yaeos__phase_equilibria_stability
use yaeos__models_ar, only: ArModel
implicit none

type mintpd_data
real(pr), allocatable :: di(:)
end type

contains

real(pr) function tm(model, z, w, P, T, d, dtpd)
Expand Down Expand Up @@ -117,6 +121,8 @@ subroutine min_tpd(model, z, P, T, mintpd, w, all_minima)
real(pr), optional, intent(out) :: all_minima(:, :)
!! All the found minima

type(mintpd_data) :: func_data

real(pr) :: dx(size(w))
real(pr) :: lnphi_z(size(z)), di(size(z))

Expand All @@ -128,12 +134,12 @@ subroutine min_tpd(model, z, P, T, mintpd, w, all_minima)

integer :: stat

f = create_nlopt_func(foo)
f = create_nlopt_func(foo, f_data=func_data)
dx = 0.001_pr

! Calculate feed di
call model%lnphi_pt(z, T=T, P=P, V=V, root_type="stable", lnPhi=lnPhi_z)
di = log(z) + lnphi_z
func_data%di = log(z) + lnphi_z


! ==============================================================
Expand All @@ -149,15 +155,15 @@ subroutine min_tpd(model, z, P, T, mintpd, w, all_minima)
! Minimize for each component using each quasi-pure component
! as initialization.
! --------------------------------------------------------------
!$OMP PARALLEL DO PRIVATE(i, w, mintpd, stat) SHARED(opt, ws, mins)
! !$OMP PARALLEL DO PRIVATE(i, w, mintpd, stat) SHARED(opt, ws, mins)
do i=1,size(w)
w = 0.001_pr
w(i) = 0.999_pr
call opt%optimize(w, mintpd, stat)
mins(i) = mintpd
ws(i, :) = w
end do
!$OMP END PARALLEL DO
! !$OMP END PARALLEL DO

i = minloc(mins, dim=1)
mintpd = mins(i)
Expand All @@ -171,7 +177,12 @@ real(pr) function foo(x, gradient, func_data)
real(pr), intent(in) :: x(:)
real(pr), optional, intent(in out) :: gradient(:)
class(*), optional, intent(in) :: func_data
foo = tm(model, z, x, P, T, d=di)

select type(func_data)
type is (mintpd_data)
foo = tm(model, z, x, P, T, d=func_data%di)
end select

end function foo
end subroutine min_tpd
end module yaeos__phase_equilibria_stability
Loading