# Need Gibbs Seawater (GSW) Equation of State to be ported to Julia

**URL:** <https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476>\
**Category:** Geo\
**Created:** [October 30, 2019, 3:40am UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476 "2019-10-30T03:40:49Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [November 6, 2019, 12:32am UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476/22 "2019-11-06T00:32:34Z")

</div>

Ahhh, i know whats happening, give one moment and i fix the error on the last master (the number 6 comes from m.Aijindices

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [November 6, 2019, 12:33am UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476/23 "2019-11-06T00:33:34Z")

</div>

I really appreciate it! I figured it’s not a big deal, let me know if I can help in anyway :). But getting molar or mass density would immediately make your package better then CoolProp!

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [November 6, 2019, 12:39am UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476/24 "2019-11-06T00:39:27Z")

</div>

```julia
pressure(m,2u"kg/m^3",300u"K",[0.1,0.2])

```

pressure accepts molar fractions, the sum of that isn’t 1.0, but that isn’t the problem anyway.  
also. in the last master i added a pt\_flash function, if you want to test (it has a lot of errors, but for simple phases works) (i updated just now)

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [November 6, 2019, 1:53am UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476/25 "2019-11-06T01:53:08Z")

</div>

Works great now!

I’ll keep playing with it.

---

<div class="post-metadata">

**Author:** ![hafez\_ahmad](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hafez_ahmad/32/14423_2.png) [@hafez\_ahmad](https://discourse.julialang.org/u/hafez_ahmad)\
**Post date:** [July 12, 2020, 6:10pm UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476/26 "2020-07-12T18:10:09Z")

</div>

why I am getting error?

> C=[56.6, 6.0 ,7.7]  
> T=[6.7 ,8.8, 8.0]  
> P=[10.9 , 77.0 ,88.0]
> 
> sp=gsw\_sp\_from\_c(C,T,P)  
> ERROR: MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type Float64  
> Closest candidates are:  
> convert(::Type{T}, ::T) where T\<:Number at number.jl:6  
> convert(::Type{T}, ::Number) where T\<:Number at number.jl:7  
> convert(::Type{T}, ::Base.TwicePrecision) where T\<:Number at twiceprecision.jl:250  
> …  
> Stacktrace:  
> [1] cconvert(::Type{T} where T, ::Array{Float64,1}) at .\essentials.jl:390  
> [2] gsw\_sp\_from\_c(::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1}) at C:\Users\hafez.julia\packages\GibbsSeaWater\NcNJk\src\gen\_gswteos10.jl:622  
> [3] top-level scope at none:0

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [July 12, 2020, 9:21pm UTC](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476/27 "2020-07-12T21:21:55Z")

</div>

That error happened because that function accepts numbers, not vectors. It can be solved via broadcasting the function over the vector arguments: `gsw_sp_from_c.(C, T, P) `

[Previous page](https://discourse.julialang.org/t/need-gibbs-seawater-gsw-equation-of-state-to-be-ported-to-julia/30476.md?page=1)
