Closed FlorianWilhelm closed 2 years ago
Thanks to have reported this issue. We will fix it soon and make a new release.
And sorry for the late reply!
Hi @gouarin, thanks for taking care of this 🙂 . Could you also give me a reference to the airconditioning demo? I would love to understand the math some more. This would be really appreciated. Thank you.
@bgraille could you reply since you have implemented this example?
Hi @FlorianWilhelm. For this simulation, we use a vectorial scheme (D2Q9 for the fluid and D2Q5 for the temperature) to discretize the Boussinesq approximation. The reference paper is the following: http://dx.doi.org/10.1016/j.camwa.2012.07.001
Thanks @bgraille!
hello ,could you tell me why this code didn't work? i use the 'M' instead of 'polynomials' in 'schemes'
`import numpy as np import sympy as sp import pylab as plt %matplotlib inline from mpl_toolkits.axes_grid1 import make_axes_locatable import pylbm
u, X, Y ,LA= sp.symbols('u, X, Y,LA')
def solution(x, y, t, k, l): return np.sin(knp.pix)np.sin(lnp.piy)np.exp(-(k2+l2)*np.pi*2mu*t)
def plot(i, j, z, title): im = axarr[i,j].imshow(z) divider = make_axes_locatable(axarr[i, j]) cax = divider.append_axes("right", size="20%", pad=0.05) cbar = plt.colorbar(im, cax=cax, format='%6.0e') axarr[i, j].xaxis.set_visible(False) axarr[i, j].yaxis.set_visible(False) axarr[i, j].set_title(title)
xmin, xmax, ymin, ymax = 0., 1., 0., 1. N = 128 mu = 1. Tf = .1 dx = (xmax-xmin)/N # spatial step la = 1./dx s1 = 2./(1+4*mu) s2 = 1. k, l = 1, 1 # number of the wave
dico = { 'box': {'x':[xmin, xmax], 'y':[ymin, ymax], 'label': 0}, 'space_step': dx, 'scheme_velocity': la, 'schemes':[ { 'velocities': list(range(5)), 'conserved_moments': u, 'M':s[p.eye(),
'equilibrium': [u, 0., 0., .5*u, 0.],
'relaxation_parameters': [0., s1, s1, s2, s2],
}
],
'init': {u: (solution, (0., k, l))},
'boundary_conditions': {
0: {'method': {0: pylbm.bc.AntiBounceBack,}},
},
'generator': 'cython',
'parameters': {LA: la},
}
sol = pylbm.Simulation(dico) x = sol.domain.x y = sol.domain.y
f, axarr = plt.subplots(2, 2) f.suptitle('Heat equation', fontsize=20)
plot(0, 0, sol.m[u].copy(), 'initial')
while sol.t < Tf: sol.one_time_step()
sol.f2m() z = sol.m[u] ze = solution(x[:, np.newaxis], y[np.newaxis, :], sol.t, k, l) plot(1, 0, z, 'final') plot(0, 1, ze, 'exact') plot(1, 1, z-ze, 'error')
plt.show()`
@FlorianWilhelm
I have no clue, I am no expert in pylbm. That being said, isn't 'polynomials' just a necessary attribute? And please don't misuse this issue for something completely different. Open up a new one.
@wusheng-ws could you open an issue with your problem or chat with us on gitter https://gitter.im/pylbm/pylbm
@FlorianWilhelm This issue is fixed in https://github.com/pylbm/pylbm/pull/162
And I made a new release(0.8.0) of pylbm wth the patch.
Thanks @gouarin!
It seems like Sympy 1.9 made some internal changes, which lead to an
AttributeError: can't set attribute
when runningpylbm.Simulation
(see full error log below). My guess is that they now useNamedTuple
or something similar as an internal data structure now, which is immutable. Going back go Sympy 1.8 solved this issue.I was running the airconditioning demo to test this. BTW, really cool project! Would you mind to also add some more comments to those examples? I guess it's the convection-diffusion, right? Or at least some pointers would be really helpful, thanks.