polymers/physics/single_chain/fjc/thermodynamics/isotensional/
mod.rs

1#[cfg(feature = "extern")]
2pub mod ex;
3
4#[cfg(feature = "python")]
5pub mod py;
6
7mod test;
8
9/// The freely-jointed chain (FJC) model thermodynamics in the isotensional ensemble approximated using a Legendre transformation.
10pub mod legendre;
11
12use std::f64::consts::PI;
13use crate::physics::
14{
15    PLANCK_CONSTANT,
16    BOLTZMANN_CONSTANT
17};
18
19/// The structure of the thermodynamics of the FJC model in the isotensional ensemble.
20pub struct FJC
21{
22    /// The mass of each hinge in the chain in units of kg/mol.
23    pub hinge_mass: f64,
24
25    /// The length of each link in the chain in units of nm.
26    pub link_length: f64,
27
28    /// The number of links in the chain.
29    pub number_of_links: u8,
30
31    /// The thermodynamic functions of the model in the isotensional ensemble approximated using a Legendre transformation.
32    pub legendre: legendre::FJC
33}
34
35/// The expected end-to-end length as a function of the applied force and temperature, parameterized by the number of links and link length.
36pub fn end_to_end_length(number_of_links: &u8, link_length: &f64, force: &f64, temperature: &f64) -> f64
37{
38    let nondimensional_force = force/BOLTZMANN_CONSTANT/temperature*link_length;
39    (1.0/nondimensional_force.tanh() - 1.0/nondimensional_force)*(*number_of_links as f64)*link_length
40}
41
42/// The expected end-to-end length per link as a function of the applied force and temperature, parameterized by the number of links and link length.
43pub fn end_to_end_length_per_link(link_length: &f64, force: &f64, temperature: &f64) -> f64
44{
45    let nondimensional_force = force/BOLTZMANN_CONSTANT/temperature*link_length;
46    (1.0/nondimensional_force.tanh() - 1.0/nondimensional_force)*link_length
47}
48
49/// The expected nondimensional end-to-end length as a function of the applied nondimensional force, parameterized by the number of links.
50pub fn nondimensional_end_to_end_length(number_of_links: &u8, nondimensional_force: &f64) -> f64
51{
52    (1.0/nondimensional_force.tanh() - 1.0/nondimensional_force)*(*number_of_links as f64)
53}
54
55/// The expected nondimensional end-to-end length per link as a function of the applied nondimensional force.
56pub fn nondimensional_end_to_end_length_per_link(nondimensional_force: &f64) -> f64
57{
58    1.0/nondimensional_force.tanh() - 1.0/nondimensional_force
59}
60
61/// The Gibbs free energy as a function of the applied nondimensional force and temperature, parameterized by the number of links and link length.
62pub fn gibbs_free_energy(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, force: &f64, temperature: &f64) -> f64
63{
64    relative_gibbs_free_energy(number_of_links, link_length, force, temperature) - (*number_of_links as f64)*BOLTZMANN_CONSTANT*temperature*(8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln()
65}
66
67/// The Gibbs free energy per link as a function of the applied nondimensional force and temperature, parameterized by the link length.
68pub fn gibbs_free_energy_per_link(link_length: &f64, hinge_mass: &f64, force: &f64, temperature: &f64) -> f64
69{
70    relative_gibbs_free_energy_per_link(link_length, force, temperature) - BOLTZMANN_CONSTANT*temperature*(8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln()
71}
72
73/// The relative Gibbs free energy as a function of the applied nondimensional force and temperature, parameterized by the number of links and link length.
74pub fn relative_gibbs_free_energy(number_of_links: &u8, link_length: &f64, force: &f64, temperature: &f64) -> f64
75{
76    nondimensional_relative_gibbs_free_energy(number_of_links, &(force/BOLTZMANN_CONSTANT/temperature*link_length))*BOLTZMANN_CONSTANT*temperature
77}
78
79/// The relative Gibbs free energy per link as a function of the applied nondimensional force and temperature, parameterized by the link length.
80pub fn relative_gibbs_free_energy_per_link(link_length: &f64, force: &f64, temperature: &f64) -> f64
81{
82    nondimensional_relative_gibbs_free_energy_per_link(&(force/BOLTZMANN_CONSTANT/temperature*link_length))*BOLTZMANN_CONSTANT*temperature
83}
84
85/// The nondimensional Gibbs free energy as a function of the applied nondimensional force and temperature, parameterized by the number of links, link length, and hinge mass.
86pub fn nondimensional_gibbs_free_energy(number_of_links: &u8, link_length: &f64, hinge_mass: &f64, nondimensional_force: &f64, temperature: &f64) -> f64
87{
88    (*number_of_links as f64)*(-(nondimensional_force.sinh()/nondimensional_force).ln() - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln())
89}
90
91/// The nondimensional Gibbs free energy per link as a function of the applied nondimensional force and temperature, parameterized by the link length and hinge mass.
92pub fn nondimensional_gibbs_free_energy_per_link(link_length: &f64, hinge_mass: &f64, nondimensional_force: &f64, temperature: &f64) -> f64
93{
94    -(nondimensional_force.sinh()/nondimensional_force).ln() - (8.0*PI.powi(2)*hinge_mass*link_length.powi(2)*BOLTZMANN_CONSTANT*temperature/PLANCK_CONSTANT.powi(2)).ln()
95}
96
97/// The nondimensional relative Gibbs free energy as a function of the applied nondimensional force, parameterized by the number of links.
98pub fn nondimensional_relative_gibbs_free_energy(number_of_links: &u8, nondimensional_force: &f64) -> f64
99{
100    -(*number_of_links as f64)*(nondimensional_force.sinh()/nondimensional_force).ln()
101}
102
103/// The nondimensional relative Gibbs free energy per link as a function of the applied nondimensional force.
104pub fn nondimensional_relative_gibbs_free_energy_per_link(nondimensional_force: &f64) -> f64
105{
106    -(nondimensional_force.sinh()/nondimensional_force).ln()
107}
108
109/// The implemented functionality of the thermodynamics of the FJC model in the isotensional ensemble.
110impl FJC
111{
112    /// Initializes and returns an instance of the thermodynamics of the FJC model in the isotensional ensemble.
113    pub fn init(number_of_links: u8, link_length: f64, hinge_mass: f64) -> Self
114    {
115        FJC
116        {
117            hinge_mass,
118            link_length,
119            number_of_links,
120            legendre: legendre::FJC::init(number_of_links, link_length, hinge_mass)
121        }
122    }
123    /// The expected end-to-end length as a function of the applied force and temperature.
124    pub fn end_to_end_length(&self, force: &f64, temperature: &f64) -> f64
125    {
126        end_to_end_length(&self.number_of_links, &self.link_length, force, temperature)
127    }
128    /// The expected end-to-end length per link as a function of the applied force and temperature.
129    pub fn end_to_end_length_per_link(&self, force: &f64, temperature: &f64) -> f64
130    {
131        end_to_end_length_per_link(&self.link_length, force, temperature)
132    }
133    /// The expected nondimensional end-to-end length as a function of the applied nondimensional force.
134    pub fn nondimensional_end_to_end_length(&self, nondimensional_force: &f64) -> f64
135    {
136        nondimensional_end_to_end_length(&self.number_of_links, nondimensional_force)
137    }
138    /// The expected nondimensional end-to-end length per link as a function of the applied nondimensional force.
139    pub fn nondimensional_end_to_end_length_per_link(&self, nondimensional_force: &f64) -> f64
140    {
141        nondimensional_end_to_end_length_per_link(nondimensional_force)
142    }
143    /// The Gibbs free energy as a function of the applied force and temperature.
144    pub fn gibbs_free_energy(&self, force: &f64, temperature: &f64) -> f64
145    {
146        gibbs_free_energy(&self.number_of_links, &self.link_length, &self.hinge_mass, force, temperature)
147    }
148    /// The Gibbs free energy per link as a function of the applied force and temperature.
149    pub fn gibbs_free_energy_per_link(&self, force: &f64, temperature: &f64) -> f64
150    {
151        gibbs_free_energy_per_link(&self.link_length, &self.hinge_mass, force, temperature)
152    }
153    /// The relative Gibbs free energy as a function of the applied force and temperature.
154    pub fn relative_gibbs_free_energy(&self, force: &f64, temperature: &f64) -> f64
155    {
156        relative_gibbs_free_energy(&self.number_of_links, &self.link_length, force, temperature)
157    }
158    /// The relative Gibbs free energy per link as a function of the applied force and temperature.
159    pub fn relative_gibbs_free_energy_per_link(&self, force: &f64, temperature: &f64) -> f64
160    {
161        relative_gibbs_free_energy_per_link(&self.link_length, force, temperature)
162    }
163    /// The nondimensional Gibbs free energy as a function of the applied nondimensional force and temperature.
164    pub fn nondimensional_gibbs_free_energy(&self, nondimensional_force: &f64, temperature: &f64) -> f64
165    {
166        nondimensional_gibbs_free_energy(&self.number_of_links, &self.link_length, &self.hinge_mass, nondimensional_force, temperature)
167    }
168    /// The nondimensional Gibbs free energy per link as a function of the applied nondimensional force and temperature.
169    pub fn nondimensional_gibbs_free_energy_per_link(&self, nondimensional_force: &f64, temperature: &f64) -> f64
170    {
171        nondimensional_gibbs_free_energy_per_link(&self.link_length, &self.hinge_mass, nondimensional_force, temperature)
172    }
173    /// The nondimensional relative Gibbs free energy as a function of the applied nondimensional force.
174    pub fn nondimensional_relative_gibbs_free_energy(&self, nondimensional_force: &f64) -> f64
175    {
176        nondimensional_relative_gibbs_free_energy(&self.number_of_links, nondimensional_force)
177    }
178    /// The nondimensional relative Gibbs free energy per link as a function of the applied nondimensional force.
179    pub fn nondimensional_relative_gibbs_free_energy_per_link(&self, nondimensional_force: &f64) -> f64
180    {
181        nondimensional_relative_gibbs_free_energy_per_link(nondimensional_force)
182    }
183}