#[cfg(feature = "extern")]
pub mod ex;
#[cfg(feature = "python")]
pub mod py;
mod test;
pub mod legendre;
use std::f64::consts::PI;
use crate::physics::
{
PLANCK_CONSTANT,
BOLTZMANN_CONSTANT
};
use crate::physics::single_chain::ZERO;
pub struct SWFJC
{
pub hinge_mass: f64,
pub link_length: f64,
pub number_of_links: u8,
pub well_width: f64,
pub legendre: legendre::SWFJC
}
pub fn end_to_end_length(number_of_links: &u8, link_length: &f64, well_width: &f64, force: &f64, temperature: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
let nondimensional_force = force*link_length/BOLTZMANN_CONSTANT/temperature;
(*number_of_links as f64)*link_length*((nondimensional_well_parameter.powi(2)*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.sinh())/(nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()) - 3.0/nondimensional_force)
}
pub fn end_to_end_length_per_link(link_length: &f64, well_width: &f64, force: &f64, temperature: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
let nondimensional_force = force*link_length/BOLTZMANN_CONSTANT/temperature;
link_length*((nondimensional_well_parameter.powi(2)*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.sinh())/(nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()) - 3.0/nondimensional_force)
}
pub fn nondimensional_end_to_end_length(number_of_links: &u8, link_length: &f64, well_width: &f64, nondimensional_force: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
(*number_of_links as f64)*((nondimensional_well_parameter.powi(2)*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.sinh())/(nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()) - 3.0/nondimensional_force)
}
pub fn nondimensional_end_to_end_length_per_link(link_length: &f64, well_width: &f64, nondimensional_force: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
(nondimensional_well_parameter.powi(2)*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.sinh())/(nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()) - 3.0/nondimensional_force
}
pub fn gibbs_free_energy(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, well_width: &f64, force: &f64, temperature: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
let nondimensional_force = force*link_length/BOLTZMANN_CONSTANT/temperature;
(*number_of_links as f64)*BOLTZMANN_CONSTANT*temperature*((3.0*nondimensional_force.ln() - (nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()).ln()) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
}
pub fn gibbs_free_energy_per_link(link_length: &f64, hinge_mass: &f64, well_width: &f64, force: &f64, temperature: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
let nondimensional_force = force*link_length/BOLTZMANN_CONSTANT/temperature;
BOLTZMANN_CONSTANT*temperature*((3.0*nondimensional_force.ln() - (nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()).ln()) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
}
pub fn relative_gibbs_free_energy(number_of_links: &u8, link_length: &f64, well_width: &f64, force: &f64, temperature: &f64) -> f64
{
gibbs_free_energy(number_of_links, link_length, &1.0, well_width, force, temperature) - gibbs_free_energy(number_of_links, link_length, &1.0, well_width, &(ZERO*BOLTZMANN_CONSTANT*temperature/link_length), temperature)
}
pub fn relative_gibbs_free_energy_per_link(link_length: &f64, well_width: &f64,force: &f64, temperature: &f64) -> f64
{
gibbs_free_energy_per_link(link_length, &1.0, well_width, force, temperature) - gibbs_free_energy_per_link(link_length, &1.0, well_width, &(ZERO*BOLTZMANN_CONSTANT*temperature/link_length), temperature)
}
pub fn nondimensional_gibbs_free_energy(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, well_width: &f64, nondimensional_force: &f64, temperature: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
(*number_of_links as f64)*((3.0*nondimensional_force.ln() - (nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()).ln()) - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
}
pub fn nondimensional_gibbs_free_energy_per_link(link_length: &f64, hinge_mass: &f64, well_width: &f64, nondimensional_force: &f64, temperature: &f64) -> f64
{
let nondimensional_well_parameter = 1.0 + well_width/link_length;
3.0*nondimensional_force.ln() - (nondimensional_well_parameter*nondimensional_force*(nondimensional_well_parameter*nondimensional_force).cosh() - (nondimensional_well_parameter*nondimensional_force).sinh() - nondimensional_force*nondimensional_force.cosh() + nondimensional_force.sinh()).ln() - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln()
}
pub fn nondimensional_relative_gibbs_free_energy(number_of_links: &u8, link_length: &f64, well_width: &f64, nondimensional_force: &f64) -> f64
{
nondimensional_gibbs_free_energy(number_of_links, link_length, &1.0, well_width, nondimensional_force, &300.0) - nondimensional_gibbs_free_energy(number_of_links, link_length, &1.0, well_width, &ZERO, &300.0)
}
pub fn nondimensional_relative_gibbs_free_energy_per_link(link_length: &f64, well_width: &f64, nondimensional_force: &f64) -> f64
{
nondimensional_gibbs_free_energy_per_link(link_length, &1.0, well_width, nondimensional_force, &300.0) - nondimensional_gibbs_free_energy_per_link(link_length, &1.0, well_width, &ZERO, &300.0)
}
impl SWFJC
{
pub fn init(number_of_links: u8, link_length: f64, hinge_mass: f64, well_width: f64) -> Self
{
SWFJC
{
hinge_mass,
link_length,
number_of_links,
well_width,
legendre: self::legendre::SWFJC::init(number_of_links, link_length, hinge_mass, well_width)
}
}
pub fn end_to_end_length(&self, force: &f64, temperature: &f64) -> f64
{
end_to_end_length(&self.number_of_links, &self.link_length, &self.well_width, force, temperature)
}
pub fn end_to_end_length_per_link(&self, force: &f64, temperature: &f64) -> f64
{
end_to_end_length_per_link(&self.link_length, &self.well_width, force, temperature)
}
pub fn nondimensional_end_to_end_length(&self, nondimensional_force: &f64) -> f64
{
nondimensional_end_to_end_length(&self.number_of_links, &self.link_length, &self.well_width, nondimensional_force)
}
pub fn nondimensional_end_to_end_length_per_link(&self, nondimensional_force: &f64) -> f64
{
nondimensional_end_to_end_length_per_link(&self.link_length, &self.well_width, nondimensional_force)
}
pub fn gibbs_free_energy(&self, force: &f64, temperature: &f64) -> f64
{
gibbs_free_energy(&self.number_of_links, &self.link_length, &self.hinge_mass, &self.well_width, force, temperature)
}
pub fn gibbs_free_energy_per_link(&self, force: &f64, temperature: &f64) -> f64
{
gibbs_free_energy_per_link(&self.link_length, &self.hinge_mass, &self.well_width, force, temperature)
}
pub fn relative_gibbs_free_energy(&self, force: &f64, temperature: &f64) -> f64
{
relative_gibbs_free_energy(&self.number_of_links, &self.link_length, &self.well_width, force, temperature)
}
pub fn relative_gibbs_free_energy_per_link(&self, force: &f64, temperature: &f64) -> f64
{
relative_gibbs_free_energy_per_link(&self.link_length, &self.well_width, force, temperature)
}
pub fn nondimensional_gibbs_free_energy(&self, nondimensional_force: &f64, temperature: &f64) -> f64
{
nondimensional_gibbs_free_energy(&self.number_of_links, &self.link_length, &self.hinge_mass, &self.well_width, nondimensional_force, temperature)
}
pub fn nondimensional_gibbs_free_energy_per_link(&self, nondimensional_force: &f64, temperature: &f64) -> f64
{
nondimensional_gibbs_free_energy_per_link(&self.link_length, &self.hinge_mass, &self.well_width, nondimensional_force, temperature)
}
pub fn nondimensional_relative_gibbs_free_energy(&self, nondimensional_force: &f64) -> f64
{
nondimensional_relative_gibbs_free_energy(&self.number_of_links, &self.link_length, &self.well_width, nondimensional_force)
}
pub fn nondimensional_relative_gibbs_free_energy_per_link(&self, nondimensional_force: &f64) -> f64
{
nondimensional_relative_gibbs_free_energy_per_link(&self.link_length, &self.well_width, nondimensional_force)
}
}