Skip to content

Commit

Permalink
Merge pull request #78 from sandialabs/dev
Browse files Browse the repository at this point in the history
documentation, public/private changes
  • Loading branch information
mrbuche authored Jan 5, 2023
2 parents 0ccc672 + 68d5b10 commit 9ac5840
Show file tree
Hide file tree
Showing 33 changed files with 197 additions and 118 deletions.
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polymers"
version = "0.0.3"
version = "0.0.4"
edition = "2021"
description = "Polymers Modeling Library"
license = "BSD-3-Clause"
Expand Down
21 changes: 5 additions & 16 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,14 @@
## Installation

[![Crates.io](https://img.shields.io/crates/v/polymers?logo=rust&logoColor=000000&label=Crates.io&color=32592f)](https://crates.io/crates/polymers)
[![Anaconda](https://img.shields.io/conda/v/mrbuche/polymers.svg?logo=anaconda&color=3EB049&label=Anaconda)](https://anaconda.org/mrbuche/polymers)
[![Docker Hub](https://img.shields.io/docker/v/mrbuche/polymers?color=0db7ed&label=Docker%20Hub&logo=docker&logoColor=0db7ed)](https://hub.docker.com/r/mrbuche/polymers)
[![GitHub](https://img.shields.io/badge/GitHub-latest-6e5494?logo=github)](https://github.com/sandialabs/Polymers/pkgs/container/polymers)

```shell
cargo install polymers
```

```shell
conda install --channel mrbuche polymers
```

```shell
docker pull mrbuche/polymers
```
The library can be used in an existing Rust project by adding the `polymers` crate as a dependency in Cargo.toml,

```shell
docker pull ghcr.io/sandialabs/polymers
```toml
[dependencies]
polymers = "*"
```
The asterisk `*` represents the latest version of the crate, but should be changed to a specific version for stability.

## Citation

Expand Down
3 changes: 3 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#![doc = include_str!("../README.md")]

/// Models for polymer physics.
pub mod physics;
9 changes: 7 additions & 2 deletions rust/src/physics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/// Single-chain models for polymer physics.
pub mod single_chain;
static BOLTZMANN_CONSTANT: f64 = 8.314462618;
static PLANCK_CONSTANT: f64 = 1.0;

/// The Boltzmann constant in units of J/(mol⋅K).
pub static BOLTZMANN_CONSTANT: f64 = 8.314462618;

/// The Planck constant in units of J⋅ns/mol.
pub static PLANCK_CONSTANT: f64 = 0.06350779923502961;
2 changes: 1 addition & 1 deletion rust/src/physics/single_chain/efjc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
pub mod thermodynamics;
pub struct EFJC
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
use crate::physics::
{
PLANCK_CONSTANT,
Expand All @@ -12,8 +12,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64
}
impl EFJC
{
Expand All @@ -25,8 +24,7 @@ impl EFJC
link_length,
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
number_of_links_f64: number_of_links as f64
}
}
pub fn helmholtz_free_energy(&self, force: &f64, temperature: &f64) -> f64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
pub mod legendre;
use crate::physics::
{
Expand All @@ -13,8 +13,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64,
pub legendre: self::legendre::EFJC
}
impl EFJC
Expand All @@ -28,7 +27,6 @@ impl EFJC
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
legendre: self::legendre::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
use crate::physics::
{
PLANCK_CONSTANT,
Expand All @@ -12,8 +12,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64
number_of_links_f64: f64
}
impl EFJC
{
Expand All @@ -25,8 +24,7 @@ impl EFJC
link_length,
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length
number_of_links_f64: number_of_links as f64
}
}
pub fn helmholtz_free_energy(&self, force: &f64, temperature: &f64) -> f64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
pub mod alternative;
pub mod reduced;
pub mod legendre;
Expand All @@ -15,8 +15,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64,
pub alternative: self::alternative::EFJC,
pub reduced: self::reduced::EFJC,
pub legendre: self::legendre::EFJC
Expand All @@ -32,7 +31,6 @@ impl EFJC
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
alternative: self::alternative::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness),
reduced: self::reduced::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness),
legendre: self::legendre::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
use crate::physics::
{
PLANCK_CONSTANT,
Expand All @@ -12,8 +12,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64
}
impl EFJC
{
Expand All @@ -25,8 +24,7 @@ impl EFJC
link_length,
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
number_of_links_f64: number_of_links as f64
}
}
pub fn helmholtz_free_energy(&self, force: &f64, temperature: &f64) -> f64
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
pub mod legendre;
use crate::physics::
{
Expand All @@ -13,8 +13,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64,
pub legendre: self::legendre::EFJC
}
impl EFJC
Expand All @@ -28,7 +27,6 @@ impl EFJC
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
legendre: self::legendre::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
use crate::physics::
{
PLANCK_CONSTANT,
Expand All @@ -13,8 +13,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64
}
impl EFJC
{
Expand All @@ -26,8 +25,7 @@ impl EFJC
link_length,
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
number_of_links_f64: number_of_links as f64

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
pub mod asymptotic;
pub mod legendre;
use crate::physics::
Expand All @@ -15,8 +15,7 @@ pub struct EFJC
pub link_length: f64,
pub number_of_links: u8,
pub link_stiffness: f64,
pub number_of_links_f64: f64,
pub contour_length: f64,
number_of_links_f64: f64,
pub asymptotic: self::asymptotic::EFJC,
pub legendre: self::legendre::EFJC
}
Expand All @@ -31,7 +30,6 @@ impl EFJC
number_of_links,
link_stiffness,
number_of_links_f64: number_of_links as f64,
contour_length: (number_of_links as f64)*link_length,
asymptotic: self::asymptotic::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness),
legendre: self::legendre::EFJC::init(number_of_links, link_length, hinge_mass, link_stiffness)
}
Expand Down
8 changes: 4 additions & 4 deletions rust/src/physics/single_chain/efjc/thermodynamics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod test;
mod test;
pub mod isotensional;
pub struct EFJC
{
Expand All @@ -22,15 +22,15 @@ impl EFJC
}
}
}
pub fn erf(x: &f64) -> f64
fn erf(x: &f64) -> f64
{
1.0 - erfc(x)
}
pub fn erfc(x: &f64) -> f64
fn erfc(x: &f64) -> f64
{
erfcx(x)/(x.powi(2)).exp()
}
pub fn erfcx(x: &f64) -> f64
fn erfcx(x: &f64) -> f64
{
if x >= &0.0
{
Expand Down
16 changes: 15 additions & 1 deletion rust/src/physics/single_chain/fjc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
pub mod test;
mod test;

/// The thermodynamics of the FJC model.
pub mod thermodynamics;

/// The structure of the FJC model.
pub struct FJC
{
/// The mass of each hinge in the chain in units of kg/mol.
pub hinge_mass: f64,

/// The length of each link in the chain in units of nm.
pub link_length: f64,

/// The number of links in the chain.
pub number_of_links: u8,

/// The thermodynamic functions of the model.
pub thermodynamics: thermodynamics::FJC
}

/// The implemented functionality of the FJC model.
impl FJC
{
/// Initializes and returns an instance of the FJC model.
pub fn init(number_of_links: u8, link_length: f64, hinge_mass: f64) -> FJC
{
FJC
Expand Down
Loading

0 comments on commit 9ac5840

Please sign in to comment.