Skip to content

Instantly share code, notes, and snippets.

View longemen3000's full-sized avatar

Andrés Riedemann longemen3000

  • Chile
View GitHub Profile
@longemen3000
longemen3000 / assoc4.jl
Last active June 28, 2024 05:47
Exact solution for the association 2B - 2B with cross association
using Roots
function X_exact2!(K,X)
k1 = K[1,2]
k2 = K[2,1]
#this computation is equivalent to the one done in Clapeyron.X_exact1
_a = k2
_b = 1 - k2 + k1
_c = -1
denom = _b + sqrt(_b*_b - 4*_a*_c)
@longemen3000
longemen3000 / doi2bib.jl
Created December 18, 2022 00:57
doi to bibtex, Julia Version
#tested on Julia 1.8.3
using Downloads #stdlib, other versions use HTTP
const DOI2BIB_CACHE = Dict{String,String}()
function doi2bib(doi::String)
if haskey(DOI2BIB_CACHE,doi)
return DOI2BIB_CACHE[doi] #caching requests
end
@longemen3000
longemen3000 / news.md
Created August 19, 2022 15:25
Clapeyron 0.3.8 news

New features

  • bubble_pressure, bubble_temperature, dew_pressure, and dew_temperature can now support custom methods. (subtyping BubblePointMethod or DewPointMethod). the default methods are now named ChemPotBubblePressure, ChemPotBubbleTemperature,ChemPotDewPressure,ChemPotDewTemperature. you can provide some or all necessary initial conditions to those new methods:

    res = bubble_pressure(model,T,x,ChemPotBubblePressure(;y0;p0;vol0))
    
  • New bubble/dew methods based on isofugacity conditions: FugtBubblePressure, FugBubbleTemperature,FugDewPressure,FugtDewTemperature.

  • All bubble methods now support leaving some components out of the bubble phase,via the nonvolatiles keyword, supported by all available bubble solvers. similarly, all dew methods support the noncondensables keyword to leave some components out of the dew phase.

using BenchmarkTools, Random
Random.seed!(123)
BenchmarkTools.DEFAULT_PARAMETERS.time_tolerance = 1.0e-11 # may or may not matter
BenchmarkTools.DEFAULT_PARAMETERS.evals = 1 # important
#==
alternative implementation of square root.
#aproximation of the square root using the float representation as a trick
used in providing an initial value for calculations of square roots.