Skip to content

Commit

Permalink
Merge pull request #176 from sandialabs/swfjc-isometric-legendre
Browse files Browse the repository at this point in the history
Swfjc isometric legendre
  • Loading branch information
mrbuche authored Apr 18, 2023
2 parents 7b4f159 + ffdfc92 commit c1d29b8
Show file tree
Hide file tree
Showing 29 changed files with 6,366 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Legendre

using DocStringExtensions
using .......Polymers: PROJECT_ROOT
using .....SingleChain: ONE, ZERO, POINTS, integrate

"""
The structure of the thermodynamics of the FJC model in the isometric ensemble approximated using a Legendre transformation.
Expand Down Expand Up @@ -153,7 +154,7 @@ function force(
end

"""
The expected nondimensional force as a function ``\\eta`` of the applied nondimensional end-to-end length per link ``\\gamma``.
The expected nondimensional force as a function ``\\eta`` of the applied nondimensional end-to-end length per link ``\\gamma``,
```math
\\eta(\\gamma) \\sim \\mathcal{L}^{-1}(\\gamma) \\quad \\text{for } N_b\\gg 1,
Expand Down Expand Up @@ -902,17 +903,17 @@ Initializes and returns an instance of the thermodynamics of the FJC model in th
$(TYPEDSIGNATURES)
"""
function FJC(number_of_links::UInt8, link_length::Float64, hinge_mass::Float64)
normalization_nondimensional_equilibrium_distribution =
sum(
map(
index -> nondimensional_equilibrium_radial_distribution(
number_of_links,
1.0,
1e-6 + (0.5 + index) * 0.00999999,
),
collect(0.0:99.0),
normalization_nondimensional_equilibrium_distribution = integrate(
nondimensional_end_to_end_length_per_link ->
nondimensional_equilibrium_radial_distribution(
number_of_links,
1.0,
nondimensional_end_to_end_length_per_link,
),
) * 0.00999999
ZERO,
ONE,
POINTS,
)
return FJC(
number_of_links,
link_length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ end
end_to_end_length^2 *
model.equilibrium_distribution(end_to_end_length),
ZERO,
ONE,
ONE * number_of_links * link_length,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand All @@ -105,10 +105,10 @@ end
end_to_end_length ->
model.equilibrium_radial_distribution(end_to_end_length),
ZERO,
ONE,
ONE * number_of_links * link_length,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand All @@ -133,7 +133,7 @@ end
ONE,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand All @@ -155,7 +155,7 @@ end
ONE,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand Down Expand Up @@ -1250,4 +1250,5 @@ end
@test abs(residual_rel) <= parameters.rel_tol
end
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ def test_nondimensional_relative_helmholtz_free_energy(self):
)
nondimensional_relative_helmholtz_free_energy_0 = \
model.nondimensional_relative_helmholtz_free_energy(
np.array(parameters.zero*number_of_links*link_length)
np.array(parameters.zero)
)
self.assertLessEqual(
np.abs(nondimensional_relative_helmholtz_free_energy_0),
Expand Down Expand Up @@ -1939,7 +1939,7 @@ def test_nondimensional_relative_helmholtz_free_energy_per_link(self):
)
nondimensional_relative_helmholtz_free_energy_per_link_0 = \
model.nondimensional_relative_helmholtz_free_energy_per_link(
np.array(parameters.zero*number_of_links*link_length)
np.array(parameters.zero)
)
self.assertLessEqual(
np.abs(
Expand Down Expand Up @@ -2043,7 +2043,7 @@ def test_nondimensional_relative_gibbs_free_energy(self):
)
nondimensional_relative_gibbs_free_energy_0 = \
model.nondimensional_relative_gibbs_free_energy(
np.array(parameters.zero*number_of_links*link_length)
np.array(parameters.zero)
)
self.assertLessEqual(
np.abs(nondimensional_relative_gibbs_free_energy_0),
Expand Down Expand Up @@ -2074,7 +2074,7 @@ def test_nondimensional_relative_gibbs_free_energy_per_link(self):
)
nondimensional_relative_gibbs_free_energy_per_link_0 = \
model.nondimensional_relative_gibbs_free_energy_per_link(
np.array(parameters.zero*number_of_links*link_length)
np.array(parameters.zero)
)
self.assertLessEqual(
np.abs(
Expand Down
12 changes: 6 additions & 6 deletions src/physics/single_chain/fjc/thermodynamics/isometric/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ end
end_to_end_length^2 *
model.equilibrium_distribution(end_to_end_length),
ZERO,
ONE,
ONE * number_of_links * link_length,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand All @@ -105,10 +105,10 @@ end
end_to_end_length ->
model.equilibrium_radial_distribution(end_to_end_length),
ZERO,
ONE,
ONE * number_of_links * link_length,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand All @@ -133,7 +133,7 @@ end
ONE,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand All @@ -155,7 +155,7 @@ end
ONE,
POINTS,
)
@test normalization - 1.0 <= parameters.rel_tol
@test abs(normalization - 1.0) <= parameters.rel_tol
end
end

Expand Down
3 changes: 2 additions & 1 deletion src/physics/single_chain/fjc/thermodynamics/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ end
)
residual_abs =
nondimensional_helmholtz_free_energy_per_link_legendre -
nondimensional_helmholtz_free_energy_per_link_legendre_out + log(
nondimensional_helmholtz_free_energy_per_link_legendre_out +
log(
8.0 * pi^2 * hinge_mass * link_length^2 * BOLTZMANN_CONSTANT * temperature /
PLANCK_CONSTANT^2,
) / number_of_links
Expand Down
12 changes: 6 additions & 6 deletions src/physics/single_chain/mod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ Single-chain models for polymer physics.
"""
module SingleChain

include("ideal/mod.jl")
include("fjc/mod.jl")
include("efjc/mod.jl")
include("swfjc/mod.jl")
include("ufjc/mod.jl")

const ONE::Float64 = 1.0
const ZERO::Float64 = 1e-6
const POINTS::UInt128 = 64
Expand Down Expand Up @@ -107,4 +101,10 @@ parameters = Parameters(
1e2,
)

include("ideal/mod.jl")
include("fjc/mod.jl")
include("efjc/mod.jl")
include("swfjc/mod.jl")
include("ufjc/mod.jl")

end
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_force(number_of_links: u8, link_length: f64, well_width: f64, end_to_end_length: f64, temperature: f64) -> f64
{
super::force(&number_of_links, &link_length, &well_width, &end_to_end_length, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_force(link_length: f64, well_width: f64, nondimensional_end_to_end_length_per_link: f64) -> f64
{
super::nondimensional_force(&link_length, &well_width, &nondimensional_end_to_end_length_per_link)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_helmholtz_free_energy(number_of_links: u8, link_length: f64, hinge_mass: f64, well_width: f64, end_to_end_length: f64, temperature: f64) -> f64
{
super::helmholtz_free_energy(&&number_of_links, &link_length, &hinge_mass, &well_width, &end_to_end_length, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_helmholtz_free_energy_per_link(number_of_links: u8, link_length: f64, hinge_mass: f64, well_width: f64, end_to_end_length: f64, temperature: f64) -> f64
{
super::helmholtz_free_energy_per_link(&&number_of_links, &link_length, &hinge_mass, &well_width, &end_to_end_length, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_relative_helmholtz_free_energy(number_of_links: u8, link_length: f64, well_width: f64, end_to_end_length: f64, temperature: f64) -> f64
{
super::relative_helmholtz_free_energy(&number_of_links, &link_length, &well_width, &end_to_end_length, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_relative_helmholtz_free_energy_per_link(number_of_links: u8, link_length: f64, well_width: f64, end_to_end_length: f64, temperature: f64) -> f64
{
super::relative_helmholtz_free_energy_per_link(&number_of_links, &link_length, &well_width, &end_to_end_length, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_helmholtz_free_energy(number_of_links: u8, link_length: f64, hinge_mass: f64, well_width: f64, nondimensional_end_to_end_length_per_link: f64, temperature: f64) -> f64
{
super::nondimensional_helmholtz_free_energy(&&number_of_links, &link_length, &hinge_mass, &well_width, &nondimensional_end_to_end_length_per_link, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_helmholtz_free_energy_per_link(number_of_links: u8, link_length: f64, hinge_mass: f64, well_width: f64, nondimensional_end_to_end_length_per_link: f64, temperature: f64) -> f64
{
super::nondimensional_helmholtz_free_energy_per_link(&&number_of_links, &link_length, &hinge_mass, &well_width, &nondimensional_end_to_end_length_per_link, &temperature)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_relative_helmholtz_free_energy(number_of_links: u8, link_length: f64, well_width: f64, nondimensional_end_to_end_length_per_link: f64) -> f64
{
super::nondimensional_relative_helmholtz_free_energy(&number_of_links, &link_length, &well_width, &nondimensional_end_to_end_length_per_link)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_relative_helmholtz_free_energy_per_link(link_length: f64, well_width: f64, nondimensional_end_to_end_length_per_link: f64) -> f64
{
super::nondimensional_relative_helmholtz_free_energy_per_link(&link_length, &well_width, &nondimensional_end_to_end_length_per_link)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_equilibrium_distribution(number_of_links: u8, link_length: f64, well_width: f64, normalization_nondimensional_equilibrium_distribution: f64, end_to_end_length: f64) -> f64
{
super::equilibrium_distribution(&number_of_links, &link_length, &well_width, &normalization_nondimensional_equilibrium_distribution, &end_to_end_length)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_equilibrium_distribution(number_of_links: u8, link_length: f64, well_width: f64, normalization_nondimensional_equilibrium_distribution: f64, nondimensional_end_to_end_length_per_link: f64) -> f64
{
super::nondimensional_equilibrium_distribution(&number_of_links, &link_length, &well_width, &normalization_nondimensional_equilibrium_distribution, &nondimensional_end_to_end_length_per_link)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_equilibrium_radial_distribution(number_of_links: u8, link_length: f64, well_width: f64, normalization_nondimensional_equilibrium_distribution: f64, end_to_end_length: f64) -> f64
{
super::equilibrium_radial_distribution(&number_of_links, &link_length, &well_width, &normalization_nondimensional_equilibrium_distribution, &end_to_end_length)
}
#[no_mangle]
pub extern fn physics_single_chain_swfjc_thermodynamics_isometric_legendre_nondimensional_equilibrium_radial_distribution(number_of_links: u8, link_length: f64, well_width: f64, normalization_nondimensional_equilibrium_distribution: f64, nondimensional_end_to_end_length_per_link: f64) -> f64
{
super::nondimensional_equilibrium_radial_distribution(&number_of_links, &link_length, &well_width, &normalization_nondimensional_equilibrium_distribution, &nondimensional_end_to_end_length_per_link)
}
Loading

2 comments on commit c1d29b8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/81846

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" c1d29b815646824bda599ddcee2630766cc1d210
git push origin v0.3.1

Please sign in to comment.