# sw_gibbs: Gibbs Function of Seawater In marelac: Tools for Aquatic Sciences

## Description

Calculates the seawater specific gibbs free energy, including derivatives up to order 2, for a given temperature, salinity and pressure.

The Gibbs function of seawater g(S,t,p) is related to the specific enthalpy h and entropy s, by g = h - (273.15 K + t) s

## Usage

 ```1 2``` ```sw_gibbs(S = 35, t = 25, p = P-1.013253, P = 1.013253, dS = 0, dt = 0, dp = 0) ```

## Arguments

 `S ` Absolute salinity (g/kg), `t ` Temperature, degrees C, `p ` gauge or applied pressure, pressure referenced against the local atmospheric pressure, bar `P ` true pressure, bar `dS ` order of the S derivative `dt ` order of the t derivative `dp ` order of the p derivative

## Value

The Gibbs function, J/kg, or its derivative

## Note

The gibbs function is defined as the sum of a pure water part and the saline part (IAPWS-08)

The coefficients from McDougall et al., 2009 were used. For temperature, they differ slightly from Feistel 2003 and Feistel 2008, which is why, for temperatures different from 0, there is a slight offset from the estimates as from table 22 or 21 from Feistel (2008).

## Author(s)

Karline Soetaert <karline.soetaert@nioz.nl>

## References

Feistel R, 2008. A Gibbs function for seawater thermodynamics for -6 to 80 dgC and salinity up to 120 g/kg. Deep-Sea Research I, 55, 1639-1671.

McDougall TJ, Feistel R, Millero FJ, Jackett DR, Wright DG, King BA, Marion GM, Chen C-T A and Spitzer P, 2009. Calculation of the Thermophysical Properties of Seawater, Global Ship-based Repeat Hydrography Manual, IOCCP Report No. 14, ICPO Publication Series no. 134.

`sw_adtgrad`, `sw_alpha`, `sw_beta`, `sw_comp`, `sw_conserv`, `sw_cp`, `sw_dens`, `sw_depth`, `sw_enthalpy`, `sw_entropy`, `sw_kappa`, `sw_kappa_t`, `sw_sfac`, `sw_svel`, `sw_tfreeze`, `sw_tpot`
`convert_PStoAS`, to convert from practical salinity (-) to absolute salinity (g/kg)
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42``` ```# table 22 Feistel 2008 sw_gibbs(0, 0, 0) #= 101.34274 sw_gibbs(0, 0, 0, dS = 1) # 0 sw_gibbs(0, 0, 0, dt = 1) #0.147643376 sw_gibbs(0, 0, 0, dp = 1) #0.1000015694e-2 sw_gibbs(0, 0, 0, dS = 1, dp = 1) #0 sw_gibbs(0, 0, 0, dt = 1, dp = 1) #-0.677700318e-7 sw_gibbs(0, 79.85, 0) #-0.446114969e5 differs (see note) sw_gibbs(0, 79.85, 0, dt = 1) #-0.107375993e4 differs sw_gibbs(0, 79.85, 0, dp = 1) #0.102892956e-2 differs sw_gibbs(0, 79.85, 0, dS = 1, dp = 1) #0 sw_gibbs(0, 79.85, 0, dt = 1, dp = 1) #0.659051552e-6 sw_gibbs(0, 0, 998.98675) #0.977303862e5 sw_gibbs(0, 0, 998.98675, dt = 1) #0.851466502e1 sw_gibbs(0, 0, 998.98675, dp = 1) #0.956683329e-3 sw_gibbs(0, 0, 998.98675, dS = 1, dp = 1) #0 sw_gibbs(0, 0, 998.98675, dt = 1, dp = 1) #0.199079571e-6 # table 21 Feistel 2008 sw_gibbs(35.16504, 0, 0) #=0 sw_gibbs(35.16504, 0, 0, dS = 1) #0.639974067e2 differs sw_gibbs(35.16504, 0, 0, dt = 1) #=0 sw_gibbs(35.16504, 0, 0, dp = 1) #0.972661217e-3 sw_gibbs(35.16504, 0, 0, dS = 1, dp = 1) #-0.759615412e-6 sw_gibbs(35.16504, 0, 0, dt = 1, dp = 1) #0.515167556e-7 !!! sw_gibbs(100, 79.85, 0) #=-0.295243229e5 differs sw_gibbs(100, 79.85, 0, dS = 1) #0.251957276e3 sw_gibbs(100, 79.85, 0, dt = 1) #-0.917529024e3 differs sw_gibbs(100, 79.85, 0, dp = 1) #0.971006828e-3 differs sw_gibbs(100, 79.85, 0, dS = 1, dp = 1) #-0.305957802e-6 sw_gibbs(100, 79.85, 0, dt = 1, dp = 1) #0.146211315e-5 sw_gibbs(35.16504, 0, 998.98675) #=0.951294557e5 sw_gibbs(35.16504, 0, 998.98675, dS = 1) #-0.545861581e1 sw_gibbs(35.16504, 0, 998.98675, dt = 1) #0.160551219e2 sw_gibbs(35.16504, 0, 998.98675, dp = 1) #0.933770945e-3 sw_gibbs(35.16504, 0, 998.98675, dS = 1, dp = 1) #-0.640757619e-6 sw_gibbs(35.16504, 0, 998.98675, dt = 1, dp = 1) #0.245708012e-6 ```