#[cfg(feature = "extern")]
pub mod ex;
#[cfg(feature = "python")]
pub mod py;
mod test;
use std::f64::consts::PI;
use crate::physics::
{
PLANCK_CONSTANT,
BOLTZMANN_CONSTANT
};
pub struct Ideal
{
pub hinge_mass: f64,
pub link_length: f64,
pub number_of_links: u8
}
pub fn force(number_of_links: &u8, link_length: &f64, end_to_end_length: &f64, temperature: &f64) -> f64
{
3.0*end_to_end_length*BOLTZMANN_CONSTANT*temperature/(*number_of_links as f64)/link_length.powi(2)
}
pub fn nondimensional_force(nondimensional_end_to_end_length_per_link: &f64) -> f64
{
3.0*nondimensional_end_to_end_length_per_link
}
pub fn helmholtz_free_energy(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, end_to_end_length: &f64, temperature: &f64) -> f64
{
(*number_of_links as f64)*BOLTZMANN_CONSTANT*temperature*(1.5*(end_to_end_length/((*number_of_links as f64)*link_length)).powi(2) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
}
pub fn helmholtz_free_energy_per_link(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, end_to_end_length: &f64, temperature: &f64) -> f64
{
BOLTZMANN_CONSTANT*temperature*(1.5*(end_to_end_length/((*number_of_links as f64)*link_length)).powi(2) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
}
pub fn relative_helmholtz_free_energy(number_of_links: &u8, link_length: &f64, end_to_end_length: &f64, temperature: &f64) -> f64
{
nondimensional_relative_helmholtz_free_energy(number_of_links, &(end_to_end_length/((*number_of_links as f64)*link_length)))*BOLTZMANN_CONSTANT*temperature
}
pub fn relative_helmholtz_free_energy_per_link(number_of_links: &u8, link_length: &f64, end_to_end_length: &f64, temperature: &f64) -> f64
{
nondimensional_relative_helmholtz_free_energy_per_link(&(end_to_end_length/((*number_of_links as f64)*link_length)))*BOLTZMANN_CONSTANT*temperature
}
pub fn nondimensional_helmholtz_free_energy(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, nondimensional_end_to_end_length_per_link: &f64, temperature: &f64) -> f64
{
(*number_of_links as f64)*(1.5*nondimensional_end_to_end_length_per_link.powi(2) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
}
pub fn nondimensional_helmholtz_free_energy_per_link(link_length: &f64, hinge_mass: &f64, nondimensional_end_to_end_length_per_link: &f64, temperature: &f64) -> f64
{
1.5*nondimensional_end_to_end_length_per_link.powi(2) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln()
}
pub fn nondimensional_relative_helmholtz_free_energy(number_of_links: &u8, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
1.5*(*number_of_links as f64)*nondimensional_end_to_end_length_per_link.powi(2)
}
pub fn nondimensional_relative_helmholtz_free_energy_per_link(nondimensional_end_to_end_length_per_link: &f64) -> f64
{
1.5*nondimensional_end_to_end_length_per_link.powi(2)
}
pub fn equilibrium_distribution(number_of_links: &u8, link_length: &f64, end_to_end_length: &f64) -> f64
{
(1.5/PI/(*number_of_links as f64)/link_length.powi(2)).powf(1.5)*(-1.5*(end_to_end_length/link_length).powi(2)/(*number_of_links as f64)).exp()
}
pub fn nondimensional_equilibrium_distribution(number_of_links: &u8, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
(1.5/PI*(*number_of_links as f64)).powf(1.5)*(-1.5*nondimensional_end_to_end_length_per_link.powi(2)*(*number_of_links as f64)).exp()
}
pub fn equilibrium_radial_distribution(number_of_links: &u8, link_length: &f64, end_to_end_length: &f64) -> f64
{
let contour_length = (*number_of_links as f64)*link_length;
4.0*PI*(end_to_end_length/contour_length).powi(2)*(1.5/PI*(*number_of_links as f64)).powf(1.5)*(-1.5*(end_to_end_length/contour_length).powi(2)*(*number_of_links as f64)).exp()/contour_length
}
pub fn nondimensional_equilibrium_radial_distribution(number_of_links: &u8, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
4.0*PI*nondimensional_end_to_end_length_per_link.powi(2)*(1.5/PI*(*number_of_links as f64)).powf(1.5)*(-1.5*nondimensional_end_to_end_length_per_link.powi(2)*(*number_of_links as f64)).exp()
}
impl Ideal
{
pub fn init(number_of_links: u8, link_length: f64, hinge_mass: f64) -> Self
{
Ideal
{
hinge_mass,
link_length,
number_of_links
}
}
pub fn force(&self, end_to_end_length: &f64, temperature: &f64) -> f64
{
force(&self.number_of_links, &self.link_length, end_to_end_length, temperature)
}
pub fn nondimensional_force(&self, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
nondimensional_force(nondimensional_end_to_end_length_per_link)
}
pub fn helmholtz_free_energy(&self, end_to_end_length: &f64, temperature: &f64) -> f64
{
helmholtz_free_energy(&self.number_of_links, &self.link_length, &self.hinge_mass, end_to_end_length, temperature)
}
pub fn helmholtz_free_energy_per_link(&self, end_to_end_length: &f64, temperature: &f64) -> f64
{
helmholtz_free_energy_per_link(&self.number_of_links, &self.link_length, &self.hinge_mass, end_to_end_length, temperature)
}
pub fn relative_helmholtz_free_energy(&self, end_to_end_length: &f64, temperature: &f64) -> f64
{
relative_helmholtz_free_energy(&self.number_of_links, &self.link_length, end_to_end_length, temperature)
}
pub fn relative_helmholtz_free_energy_per_link(&self, end_to_end_length: &f64, temperature: &f64) -> f64
{
relative_helmholtz_free_energy_per_link(&self.number_of_links, &self.link_length, end_to_end_length, temperature)
}
pub fn nondimensional_helmholtz_free_energy(&self, nondimensional_end_to_end_length_per_link: &f64, temperature: &f64) -> f64
{
nondimensional_helmholtz_free_energy(&self.number_of_links, &self.link_length, &self.hinge_mass, nondimensional_end_to_end_length_per_link, temperature)
}
pub fn nondimensional_helmholtz_free_energy_per_link(&self, nondimensional_end_to_end_length_per_link: &f64, temperature: &f64) -> f64
{
nondimensional_helmholtz_free_energy_per_link(&self.link_length, &self.hinge_mass, nondimensional_end_to_end_length_per_link, temperature)
}
pub fn nondimensional_relative_helmholtz_free_energy(&self, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
nondimensional_relative_helmholtz_free_energy(&self.number_of_links, nondimensional_end_to_end_length_per_link)
}
pub fn nondimensional_relative_helmholtz_free_energy_per_link(&self, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
nondimensional_relative_helmholtz_free_energy_per_link(nondimensional_end_to_end_length_per_link)
}
pub fn equilibrium_distribution(&self, end_to_end_length: &f64) -> f64
{
equilibrium_distribution(&self.number_of_links, &self.link_length, end_to_end_length)
}
pub fn nondimensional_equilibrium_distribution(&self, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
nondimensional_equilibrium_distribution(&self.number_of_links, nondimensional_end_to_end_length_per_link)
}
pub fn equilibrium_radial_distribution(&self, end_to_end_length: &f64) -> f64
{
equilibrium_radial_distribution(&self.number_of_links, &self.link_length, end_to_end_length)
}
pub fn nondimensional_equilibrium_radial_distribution(&self, nondimensional_end_to_end_length_per_link: &f64) -> f64
{
nondimensional_equilibrium_radial_distribution(&self.number_of_links, nondimensional_end_to_end_length_per_link)
}
}