polymers 0.3.7

Polymers Modeling Library
Documentation
use pyo3::prelude::*;

pub fn register_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()>
{
    let thermodynamics = PyModule::new(py, "thermodynamics")?;
    super::isometric::py::register_module(py, thermodynamics)?;
    super::isotensional::py::register_module(py, thermodynamics)?;
    super::modified_canonical::py::register_module(py, thermodynamics)?;
    parent_module.add_submodule(thermodynamics)?;
    thermodynamics.add_class::<FJC>()?;
    Ok(())
}

/// The freely-jointed chain (FJC) model thermodynamics.
#[pyclass]
#[derive(Copy, Clone)]
pub struct FJC
{
    /// The mass of each hinge in the chain in units of kg/mol.
    #[pyo3(get)]
    pub hinge_mass: f64,
    
    /// The length of each link in the chain in units of nm.
    #[pyo3(get)]
    pub link_length: f64,
    
    /// The number of links in the chain.
    #[pyo3(get)]
    pub number_of_links: u8,

    /// The thermodynamic functions of the model in the isometric ensemble.
    #[pyo3(get)]
    pub isometric: super::isometric::py::FJC,

    /// The thermodynamic functions of the model in the isotensional ensemble.
    #[pyo3(get)]
    pub isotensional: super::isotensional::py::FJC,

    /// The thermodynamic functions of the model in the modified canonical ensemble.
    #[pyo3(get)]
    pub modified_canonical: super::modified_canonical::py::FJC
}

#[pymethods]
impl FJC
{
    #[new]
    pub fn init(number_of_links: u8, link_length: f64, hinge_mass: f64) -> Self
    {
        FJC
        {
            hinge_mass,
            link_length,
            number_of_links,
            isometric: super::isometric::py::FJC::init(number_of_links, link_length, hinge_mass),
            isotensional: super::isotensional::py::FJC::init(number_of_links, link_length, hinge_mass),
            modified_canonical: super::modified_canonical::py::FJC::init(number_of_links, link_length, hinge_mass)
        }
    }
}