Ideal gas reference (idealgas)#

Analytic ideal gas in 1D in an external field. The position, \(x\), may vary from \(0 \leq x \leq L\), with the field acting linearly on \(x\), \(U(x) = a x\), where for simplicity we let \(a=1\). As a result, the potential energy of a system of \(N\) particles with positions \(x_1, x_2, ... x_N\) is the sum of the positions, \(U = \sum_{i=1}^N x_i\). This is a useful test system with analytical solutions coded alongside the ability to randomly generate data.

Functions:

dbeta_xave(k)

Analytical derivative of order k w.r.t.

dbeta_xave_depend(k)

Analytical derivative of order k w.r.t.

dbeta_xave_depend_minuslog(k)

Analytical derivative of order k w.r.t.

dbeta_xave_minuslog(k)

Analytical derivative of order k w.r.t.

dvol_xave(k)

Analytical derivative of order k w.r.t.

generate_data(shape, beta[, vol, rng])

Generates data points in specified shape, where the first index is the number of samples and the second is the number of independent IG particles Sample will be at beta with L=vol Returns tuple of the particle positions in each configuration and the potential energy of each sampled configuration.

u_prob(u, npart, beta[, vol])

In the large-N limit, the probability of the potential energy is Normal, so provides that.

u_sample(shape, beta[, vol, rng])

Samples potential energy values from a system.

x_ave(beta[, vol])

Average position x at the inverse temperature beta.

x_beta_extrap(order, beta0, beta[, vol])

Analytical extrapolation and coefficients from beta0 to beta (at L=vol) using derivatives up to order

x_beta_extrap_depend(order, beta0, beta[, vol])

Same as x_beta_extrap but for <beta*x>.

x_beta_extrap_depend_minuslog(order, beta0, beta)

Same as x_beta_extrap but with -ln<beta*x>.

x_beta_extrap_minuslog(order, beta0, beta[, vol])

Same as x_beta_extrap but with -ln<x>.

x_cdf(x, beta[, vol])

Cumulative probability density for position x for single particle.

x_prob(x, beta[, vol])

Canonical probability of position x for single article at inverse temperature beta.

x_sample(shape, beta[, vol, rng])

Sample positions from distribution at beta and vol.

x_var(beta[, vol])

Variance in position, x at the inverse temperature beta.

x_vol_extrap(order, vol0, vol[, beta])

Analytical extrapolation coefficients from vol0 to vol (at beta) using derivatives up to order

thermoextrap.idealgas.dbeta_xave(k)[source]#

Analytical derivative of order k w.r.t. beta for the average of x.

Returns sympy function with expression for derivative.

thermoextrap.idealgas.dbeta_xave_depend(k)[source]#

Analytical derivative of order k w.r.t. beta for the average of beta*x

Returns sympy function with expression for derivative.

Note that this is also the average dimensionless potential energy for a single particle And since particles are independent, can just multiply by N for a system of N particles

thermoextrap.idealgas.dbeta_xave_depend_minuslog(k)[source]#

Analytical derivative of order k w.r.t. beta for -ln(<beta*x>)

Returns sympy function with expression for derivative.

thermoextrap.idealgas.dbeta_xave_minuslog(k)[source]#

Analytical derivative of order k w.r.t. beta for -ln(<x>)

Returns sympy function with expression for derivative.

thermoextrap.idealgas.dvol_xave(k)[source]#

Analytical derivative of order k w.r.t. L for average x

Returns sympy function with expression for derivative.

thermoextrap.idealgas.generate_data(shape, beta, vol=1.0, rng=None)[source]#

Generates data points in specified shape, where the first index is the number of samples and the second is the number of independent IG particles Sample will be at beta with L=vol Returns tuple of the particle positions in each configuration and the potential energy of each sampled configuration.

r may be specified as an array of random numbers instead of shape

Parameters:
thermoextrap.idealgas.u_prob(u, npart, beta, vol=1.0)[source]#

In the large-N limit, the probability of the potential energy is Normal, so provides that.

Parameters:
thermoextrap.idealgas.u_sample(shape, beta, vol=1.0, rng=None)[source]#

Samples potential energy values from a system.

Note that shape = (nsamp, npart) Particle positions are randomly sampled with x_sample() at beta to generate the configuration of the potential energy.

Parameters:
thermoextrap.idealgas.x_ave(beta, vol=1.0)[source]#

Average position x at the inverse temperature beta.

Parameters:
thermoextrap.idealgas.x_beta_extrap(order, beta0, beta, vol=1.0)[source]#

Analytical extrapolation and coefficients from beta0 to beta (at L=vol) using derivatives up to order

Returns extrapolation as first output and unnormalized coefficients as second.

Parameters:
  • order (int) – Expansion order.

  • beta0 (float) – Reference inverse temperature.

  • beta (float or ndarray) – Inverse temperature.

  • vol (float or ndarray, default 1.0) – System volume.

thermoextrap.idealgas.x_beta_extrap_depend(order, beta0, beta, vol=1.0)[source]#

Same as x_beta_extrap but for <beta*x>.

Parameters:
  • order (int) – Expansion order.

  • beta0 (float) – Reference inverse temperature.

  • beta (float or ndarray) – Inverse temperature.

  • vol (float or ndarray, default 1.0) – System volume.

thermoextrap.idealgas.x_beta_extrap_depend_minuslog(order, beta0, beta, vol=1.0)[source]#

Same as x_beta_extrap but with -ln<beta*x>.

Parameters:
  • order (int) – Expansion order.

  • beta0 (float) – Reference inverse temperature.

  • beta (float or ndarray) – Inverse temperature.

  • vol (float or ndarray, default 1.0) – System volume.

thermoextrap.idealgas.x_beta_extrap_minuslog(order, beta0, beta, vol=1.0)[source]#

Same as x_beta_extrap but with -ln<x>.

Parameters:
  • order (int) – Expansion order.

  • beta0 (float) – Reference inverse temperature.

  • beta (float or ndarray) – Inverse temperature.

  • vol (float or ndarray, default 1.0) – System volume.

thermoextrap.idealgas.x_cdf(x, beta, vol=1.0)[source]#

Cumulative probability density for position x for single particle.

Parameters:
thermoextrap.idealgas.x_prob(x, beta, vol=1.0)[source]#

Canonical probability of position x for single article at inverse temperature beta.

Parameters:
thermoextrap.idealgas.x_sample(shape, beta, vol=1.0, rng=None)[source]#

Sample positions from distribution at beta and vol.

Does sampling based on inversion of cumulative distribution function.

Parameters:
Returns:

output (ndarray) – Random sample from distribution.

Notes

If pass r, then use these to build output. Otherwise, build random array of shape shape.

thermoextrap.idealgas.x_var(beta, vol=1.0)[source]#

Variance in position, x at the inverse temperature beta.

Parameters:
thermoextrap.idealgas.x_vol_extrap(order, vol0, vol, beta=1.0)[source]#

Analytical extrapolation coefficients from vol0 to vol (at beta) using derivatives up to order

Returns extrapolation as first output and unnormalized coefficients as second.

Parameters:
  • order (int) – Expansion order.

  • vol0 (float) – Reference volume.

  • vol (float or ndarray, default 1.0) – System volume.

  • beta (float or ndarray) – Inverse temperature.