Skip to content
Merged
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
4 changes: 0 additions & 4 deletions YPF2.nml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
! CN from which all SCN fractions will be lumped into the specified number of pseudos
numbers_ps = 5
! number of pseudos in which the scn fractions grouped
density_setup = .true.
! Logical variable to choose the density calculation method
number_plus_density = 6
! CN from which we considered .......
/
&nml_components
def_components = "N2" "CO2" "C1" "C2" "C3" "iC4" "nC4" "iC5" "nC5"
Expand Down
20 changes: 7 additions & 13 deletions app/main.f90
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
program main

!use data_from_input, only: data_from_file, FluidData
use characterization

implicit none

type(FluidDataOut) :: prueba
integer :: i

prueba = characterize(file='PVT5.nml', mw_source="experimental", method = "plus_mw", pho_method = 3 , fix_C=.true., eos='PR')
write(*, *) prueba
print*, prueba%C, prueba%a, prueba%b, prueba%plus_mw, prueba%plus_z
print*, prueba%c_max

!print*, prueba%a , prueba%b , prueba%n_init, prueba%input_data%number_plus_density
!do i = 1, size(prueba%mol_fraction)
! print*, prueba%mol_fraction(i)
!end do
type(FluidDataOut) :: fluid_to_characterize

fluid_to_characterize=characterize(file='YPF2.nml', mw_source="experimental",&
method = "plus_mw", rho_method = 1 , fix_C=.TRUE., eos='PR')

call general_result( fluid_to_characterize)
write(*, *) fluid_to_characterize

end program main

Expand Down
4 changes: 2 additions & 2 deletions app/optimize.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ elemental function quad(x, a, b, c)
end module


program oscar
program test
use ForTimize, only: pr, minimize
use my_objective, only: foo, ExpData

Expand All @@ -62,4 +62,4 @@ program oscar
! Print results
print *, x
print *, F
end program oscar
end program test
39 changes: 22 additions & 17 deletions app/pedersen.f90
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module my_objective1
!! This module used ForTimize package to optimize the parameters
!! for pedersen distribution funtion
use ForTimize, only: pr


type :: ExpData
real(pr), allocatable :: x(:)
real(pr), allocatable :: zplus(:)
real(pr), allocatable :: mplus(:)
real(pr), allocatable :: x(:) !! Vector of parameters to optimize
real(pr), allocatable :: zplus(:) !! Experimental mole fraction of residual fraction
real(pr), allocatable :: mplus(:) !! Experimental molecular weight of residual fraction
end type ExpData

contains
Expand All @@ -20,25 +20,29 @@ subroutine foo(x, F, dF, data)
class(*), optional, intent(in out) :: data
!! Special data that the function could use.

real(pr) :: a, b
integer :: i
integer, parameter :: n = 181
real(pr) :: cn(n)
real(pr) :: z_i(n)
real(pr) :: m_i(n)
real(pr) :: zplus_cal
real(pr) :: mplus_cal

real(pr) :: a, b !! parameters of pedersen distribution funtion
integer :: i !! Iteration variable
integer, parameter :: n = 181 !! Parameter for defined maximum carbon number
real(pr) :: cn(n) !! Vector of carbon numbers
real(pr) :: z_i(n) !! Vector of compositions of residual fraction
real(pr) :: m_i(n) !! Vector of molecular weights of residual fraction
real(pr) :: zplus_cal !! Mole fraction of plus fraction compute
real(pr) :: mplus_cal !! Molecular weight of plus fraction compute

! compute the carbon number vector
do i = 1, n
cn(i) = 20.0d0 + i - 1
end do

! define parameters to optimizar into x vector
a = x(1)
b = x(2)

! compute mole fraction using pedersen linear funtion
z_i = exp(a*cn+b)
! compute molecular weighth using pedersen linear funtion
m_i = 14*cn-4
! Sum the values to obtain the residual value
zplus_cal = sum(z_i)
mplus_cal = sum(z_i*m_i)/zplus_cal

Expand All @@ -53,7 +57,8 @@ end subroutine foo
end module my_objective1


program oscar
program pedersen_characterize
!! This program optimizes the parameter of pedersen distribution funtion
use ForTimize, only: pr, minimize
use my_objective1, only: foo, ExpData

Expand All @@ -72,5 +77,5 @@ program oscar
! Print results
print *, x
print *, F
!print*, cn
end program oscar

end program pedersen_characterize
Loading
Loading