From 2eab12cae3310d1e5f9566325b5d6b3fbd14a824 Mon Sep 17 00:00:00 2001 From: Joakim Stenhammar Date: Thu, 21 Jan 2016 12:10:43 +0100 Subject: [PATCH 1/9] Added 'swims' option to toggle between 'shakers' and swimmers. Added individual default values of control variables. --- python/d3q15/swimmers.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/python/d3q15/swimmers.py b/python/d3q15/swimmers.py index 5f89a3b..422e597 100644 --- a/python/d3q15/swimmers.py +++ b/python/d3q15/swimmers.py @@ -65,15 +65,22 @@ def __init__(self, L, **kwargs): except KeyError: randSeed = 0 - for flag in ['walls', 'tumbles', 'sinks', 'tracks', 'forced']: + # Set default options + self.__setattr__('swims', True) + self.__setattr__('tumbles', True) + self.__setattr__('tracks', True) + self.__setattr__('walls', False) + self.__setattr__('sinks', False) + self.__setattr__('forced', False) + + for flag in ['swims', 'tumbles', 'tracks', 'walls', 'sinks', 'forced']: try: if kwargs[flag]: self.__setattr__(flag, True) else: self.__setattr__(flag, False) except KeyError: - self.__setattr__(flag, False) - continue + continue if self.tumbles: try: @@ -89,7 +96,8 @@ def __init__(self, L, **kwargs): self.eta = L.tau_s / 3. self.num = len(r_list) - + print self.num + # set up fields in data array # we only create a table if one doesn't exist already # (we might be called by a subclass that created some already) @@ -169,7 +177,13 @@ def move(self, lattice): """ v = self._interp(lattice, self.r) - rDot = self.P * self.n +# rDot = self.P * self.n + + rDot = N.zeros([self.num,3]) + if self.swims: + rDot += self.P * self.n + pass + if self.sinks: rDot += self.F pass From 77b93eedb6ea3a8c6240158b3a839776d6692c3a Mon Sep 17 00:00:00 2001 From: Joakim Stenhammar Date: Mon, 25 Jan 2016 12:14:40 +0100 Subject: [PATCH 2/9] Added "swims" keyword to simulate shakers (non-swimming stresslets) Modified swimmers.py to set default values for logical variables --- python/d3q15/swimmers.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/python/d3q15/swimmers.py b/python/d3q15/swimmers.py index 422e597..c5953d7 100644 --- a/python/d3q15/swimmers.py +++ b/python/d3q15/swimmers.py @@ -175,15 +175,10 @@ def move(self, lattice): where v(R) is the interpolated velocity at the position of the swimmer, a is the radius and n_ is the orientation. """ - v = self._interp(lattice, self.r) - -# rDot = self.P * self.n - rDot = N.zeros([self.num,3]) if self.swims: rDot += self.P * self.n pass - if self.sinks: rDot += self.F pass @@ -192,8 +187,9 @@ def move(self, lattice): pass h = self.hydroRadius - rDot *= (1./self.a - 1./h) / (6. * N.pi * self.eta) + + v = self._interp(lattice, self.r) rDot += v # rPlus = self.r From e8abb781f55c3b65ba134beb9c4fc8fafa213af3 Mon Sep 17 00:00:00 2001 From: Joakim Stenhammar Date: Mon, 25 Jan 2016 13:53:01 +0100 Subject: [PATCH 3/9] Added configurable Makefile --- libd3q15/.gitignore | 1 + libd3q15/Makefile | 3 +++ 2 files changed, 4 insertions(+) diff --git a/libd3q15/.gitignore b/libd3q15/.gitignore index af08fed..934b553 100644 --- a/libd3q15/.gitignore +++ b/libd3q15/.gitignore @@ -1 +1,2 @@ eigenvectors.h +config.mk diff --git a/libd3q15/Makefile b/libd3q15/Makefile index d30f6c1..c500b08 100644 --- a/libd3q15/Makefile +++ b/libd3q15/Makefile @@ -15,6 +15,9 @@ libobjs = d3q15.o checks.o noise.o \ headers = d3q15.h Lattice.h noise.h eigenvectors.h +localconfig = $(wildcard config.mk) +include $(localconfig) + $(LIB) : $(libobjs) $(AR) $@ $^ ranlib $@ From 5828bb35342b3f1e264886544c5da8813e15a56d Mon Sep 17 00:00:00 2001 From: Joakim Stenhammar Date: Mon, 25 Jan 2016 14:23:53 +0100 Subject: [PATCH 4/9] Make setup.py configurable --- python/.gitignore | 2 +- python/setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/python/.gitignore b/python/.gitignore index ac5a382..3623f3d 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -1,3 +1,3 @@ *.pyc build - +setup.cfg diff --git a/python/setup.py b/python/setup.py index 68b914d..12ff04c 100644 --- a/python/setup.py +++ b/python/setup.py @@ -5,6 +5,7 @@ import distutils.sysconfig from Cython.Build import cythonize import numpy +import numpy.distutils.intelccompiler numpyIncludeDir = numpy.get_include() From 647918c6e306f553c7e41358f046853f15ba027d Mon Sep 17 00:00:00 2001 From: Joakim Stenhammar Date: Mon, 25 Jan 2016 16:42:35 +0100 Subject: [PATCH 5/9] Added 'advects' and 'rotates' keywords to toggle swimmer advection / rotation by fluid Removed spurious print statement from swimmers.py --- python/d3q15/swimmers.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/python/d3q15/swimmers.py b/python/d3q15/swimmers.py index c5953d7..734f7f9 100644 --- a/python/d3q15/swimmers.py +++ b/python/d3q15/swimmers.py @@ -67,13 +67,15 @@ def __init__(self, L, **kwargs): # Set default options self.__setattr__('swims', True) + self.__setattr__('advects', True) + self.__setattr__('rotates', True) self.__setattr__('tumbles', True) self.__setattr__('tracks', True) self.__setattr__('walls', False) self.__setattr__('sinks', False) self.__setattr__('forced', False) - for flag in ['swims', 'tumbles', 'tracks', 'walls', 'sinks', 'forced']: + for flag in ['swims', 'advects', 'rotates', 'tumbles', 'tracks', 'walls', 'sinks', 'forced']: try: if kwargs[flag]: self.__setattr__(flag, True) @@ -96,7 +98,6 @@ def __init__(self, L, **kwargs): self.eta = L.tau_s / 3. self.num = len(r_list) - print self.num # set up fields in data array # we only create a table if one doesn't exist already @@ -190,16 +191,21 @@ def move(self, lattice): rDot *= (1./self.a - 1./h) / (6. * N.pi * self.eta) v = self._interp(lattice, self.r) - rDot += v + if self.advects: + rDot += v + pass # rPlus = self.r - rMinus= self.r - self.n * self.l - # from above, v = v(rPlus) - nDot = v - self._interp(lattice, rMinus) - # now nDot = v(rPlus) - v(rMinus) - # so divide by l to get the rate - nDot /= self.l - + nDot = N.zeros([self.num,3]) + if self.rotates: + rMinus = self.r - self.n * self.l + # from above, v = v(rPlus) + nDot += v - self._interp(lattice, rMinus) + # now nDot = v(rPlus) - v(rMinus) + # so divide by l to get the rate + nDot /= self.l + pass + self.applyMove(lattice, rDot) self.applyTurn(lattice, nDot) From 37e81afb678b41e0cb3d73d90ce8937f72219c11 Mon Sep 17 00:00:00 2001 From: Joakim Stenhammar Date: Wed, 10 Feb 2016 14:51:04 +0100 Subject: [PATCH 6/9] Fixed bug when copying r to s using walls in swimmers.py --- python/d3q15/swimmers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/d3q15/swimmers.py b/python/d3q15/swimmers.py index 734f7f9..4043dac 100644 --- a/python/d3q15/swimmers.py +++ b/python/d3q15/swimmers.py @@ -285,7 +285,7 @@ def applyMove(self, lattice, rdots): if self.walls: # make sure the unwrapped coords do respect the walls # by copying in the actual z - self.s[2] = self.r[2] + self.s[:,2] = self.r[:,2] return def applyTurn(self, lattice, nDots): From 3a80104a821dfc44f3a93469255fc6ee58be6fa8 Mon Sep 17 00:00:00 2001 From: Rupert Nash Date: Fri, 18 Mar 2016 12:30:14 +0000 Subject: [PATCH 7/9] Correctly use accelerations rather than forces when updating the stress --- libd3q15/d3q15.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libd3q15/d3q15.c b/libd3q15/d3q15.c index aa17e97..d716345 100644 --- a/libd3q15/d3q15.c +++ b/libd3q15/d3q15.c @@ -268,7 +268,7 @@ void collide (Lattice *lat) { /* relax the trace */ TrS -= omega_b*(TrS - site.rho[0]*usq); /* Add forcing part to trace */ - TrS += 2.*omega_b*tau_b * uDOTf; + TrS += 2.*omega_b*tau_b * uDOTf / site.rho[0]; /* and the traceless part */ for (a=0; a Date: Mon, 14 Nov 2016 10:41:03 +0100 Subject: [PATCH 8/9] Add forcing term to initialization of DFs. --- libd3q15/d3q15.c | 6 +++--- python/d3q15/Lattice.i | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libd3q15/d3q15.c b/libd3q15/d3q15.c index d716345..f0e3d36 100644 --- a/libd3q15/d3q15.c +++ b/libd3q15/d3q15.c @@ -86,11 +86,11 @@ void d3q15_iterate(Lattice *lat, int n_steps) { collide(lat); /* Update boundary */ - (*lat->bc_func)(lat); + (*lat->bc_func)(lat); /* Propagate */ propagate(lat); - + lat->time_step++; } } @@ -277,7 +277,7 @@ void collide (Lattice *lat) { site.rho[0]*(site.u[a]*site.u[b] -usq*delta[a][b])); /* including traceless force */ - S[a][b] += 2.*omega_s*tau_s * (site.u[a]*site.force[b] + site.force[a]*site.u[b] - 2. * uDOTf * delta[a][b]) / site.rho[0]; + S[a][b] += 2.*omega_s*tau_s * (site.u[a]*site.force[b] + site.force[a]*site.u[b] - 2. * uDOTf * delta[a][b]) / site.rho[0]; } /* add the trace back on */ S[a][a] += TrS / DQ_d; diff --git a/python/d3q15/Lattice.i b/python/d3q15/Lattice.i index 611dec6..420ba0c 100644 --- a/python/d3q15/Lattice.i +++ b/python/d3q15/Lattice.i @@ -315,10 +315,21 @@ EXC_CHECK(force_set) */ void initFromHydroVars() { int i, j, k; + int a; + double u[DQ_d], force[DQ_d]; + for (i=1; i<=$self->nx; i++) for (j=1; j<=$self->ny; j++) - for (k=1; k<=$self->nz; k++) - calc_equil(DQ_rho_get($self,i,j,k), &DQ_u_get($self, i,j,k,0), &DQ_f_get($self, i,j,k,0)); + for (k=1; k<=$self->nz; k++) { + for (a=0; a Date: Mon, 2 Oct 2017 14:51:21 +0200 Subject: [PATCH 9/9] Corrected error in forcing term for stress relaxation --- libd3q15/d3q15.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libd3q15/d3q15.c b/libd3q15/d3q15.c index f0e3d36..b7ea020 100644 --- a/libd3q15/d3q15.c +++ b/libd3q15/d3q15.c @@ -277,7 +277,7 @@ void collide (Lattice *lat) { site.rho[0]*(site.u[a]*site.u[b] -usq*delta[a][b])); /* including traceless force */ - S[a][b] += 2.*omega_s*tau_s * (site.u[a]*site.force[b] + site.force[a]*site.u[b] - 2. * uDOTf * delta[a][b]) / site.rho[0]; + S[a][b] += omega_s*tau_s * (site.u[a]*site.force[b] + site.force[a]*site.u[b] - 2. * uDOTf * delta[a][b]) / site.rho[0]; } /* add the trace back on */ S[a][a] += TrS / DQ_d;