From 394a8eba78178a02c2fc1ef9f128caa16a0a22b3 Mon Sep 17 00:00:00 2001 From: Pim Nelissen Date: Fri, 24 Oct 2025 12:51:38 +0200 Subject: [PATCH] update link and rubberband structures --- Link.py | 2 +- RubberBand.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Link.py b/Link.py index f7f7274..ece6a1d 100644 --- a/Link.py +++ b/Link.py @@ -8,4 +8,4 @@ class Link: direction (int) The direction. Must be 1 or -1. """ - self.direction = direction + self.direction = direction \ No newline at end of file diff --git a/RubberBand.py b/RubberBand.py index 4fa61f6..7ee6e76 100644 --- a/RubberBand.py +++ b/RubberBand.py @@ -3,7 +3,10 @@ import numpy as np from Link import Link class RubberBand: - def __init__(self, N, a=1.): + # class attributes + k_B = 1 + + def __init__(self, N, a=1., T=1.): """ RubberBand is a class that can simulate a rubber band with N incompressible links of length a. @@ -11,16 +14,22 @@ class RubberBand: Parameters: N (int) The number of links. a (float) The fixed length of links. + T (float) Temperature of the system. """ self.N = N self.a = a + self.T = T self.links = self.__sample_links() + def w(self, f, l): + beta = (self.k_B*self.T)**(-1) + return np.exp(beta*f*l) + @property def length(self): return self.a * np.sum([l.direction for l in self.links]) - + def __sample_links(self): """ Sample N Link objects with a random direction. @@ -30,6 +39,4 @@ class RubberBand: directions = np.ones(samples.shape) directions[samples < 0.5] = -1. directions = directions.astype(int) - return [Link(d) for d in directions] - - + return [Link(d) for d in directions] \ No newline at end of file