Comments (3)
Thank you for opening this issue @fidle.
Correct me if I am wrong, but I think you are referring to In [5]
and In [6]
in Lesson 06 (06_Array_Operations_with_NumPy.ipynb
).
If so, the parenthesis in In [6]
are indeed misplaced.
Here is a small example that reflects this issue:
> python
Python 3.6.8 |Anaconda custom (64-bit)| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.15.4'
>>> c = 1.0
>>> dx = 2 / 80
>>> dy = 2 / 80
>>> sigma = 0.2
>>> dt = sigma * dx
>>> un = numpy.random.rand(80, 80)
>>> u1 = un[1:, 1:] - ((c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) - (c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))
>>> u2 = (un[1:, 1:] - (c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) - (c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))
>>> numpy.allclose(u1, u2)
False
>>>
Since you found the bug @fidle, would you like to provide a patch in a pull-request?
from cfdpython.
sorry to reply you so late. @mesnardo
you are right , the parenthesis in In[6] is misplace. I am sorry I did make it clear in the issue.
I hope I could make a pull-request. but I don't know how(I am a fresh man in github).
I rewrite this part to make the code output a result, so people can see that both method can get the same result.
here is the code
`import numpy
from matplotlib import pyplot
nx = 81
ny = 81
dx = 2/(nx-1)
dy = 2/(ny-1)
c = 1
nt = 100
sigma =0.2
dt = sigma*dx
x = numpy.linspace(0,2,nx)
y = numpy.linspace(0,2,ny)
%%timeit
u = numpy.ones((ny, nx))
u[int(.5 / dy): int(1 / dy + 1), int(.5 / dx):int(1 / dx + 1)] = 2
for n in range(nt + 1): ##loop across number of time steps
un = u.copy()
row, col = u.shape
for j in range(1, row):
for i in range(1, col):
u[j, i] = (un[j, i] - (c * dt / dx *
(un[j, i] - un[j, i - 1])) -
(c * dt / dy *
(un[j, i] - un[j - 1, i])))
u[0, :] = 1
u[-1, :] = 1
u[:, 0] = 1
u[:, -1] = 1
pyplot.pcolormesh(u)`
`%%timeit
u = numpy.ones((ny, nx))
u[int(.5 / dy): int(1 / dy + 1), int(.5 / dx):int(1 / dx + 1)] = 2
for n in range(nt + 1): ##loop across number of time steps
un = u.copy()
u[1:, 1:] = un[1:, 1:] - (c * dt / dx * (un[1:, 1:] - un[1:, 0:-1]))-(c * dt / dy * (un[1:, 1:] - un[0:-1, 1:]))
u[0, :] = 1
u[-1, :] = 1
u[:, 0] = 1
u[:, -1] = 1
pyplot.pcolormesh(u)`
from cfdpython.
Thank you @fidle.
I opened a pull-request to correct the parenthesis.
Here are the steps I did to submit a pull-request:
- I forked the repository
barbagroup/CFDPython
to my GitHub account. - On my local machine, I cloned the forked repository
mesnardo/CFDPython
. - I created a new branch called
misplaced-parenthesis
from themaster
branch. - I corrected the Notebook (based on your report) and re-ran the entire Notebook.
- I committed and pushed to
mesnardo/CFDPython
to the branchmisplaced-parenthesis
. - On GitHub, I created a pull-request to request a merge from my branch
misplaced-parenthesis
to themaster
branch ofbarbagroup/CFDPython
(see PR #61). - I am now waiting for one of the maintainers to review and approve my pull-request and to finalize the merge.
(@fidle, I gave you credit in the commit message 3c692c4.)
from cfdpython.
Related Issues (20)
- Statement of need could be more clear about the target audience
- Pressure is -ve in 11th step
- 11 step, d(div(U))/dt term HOT 2
- Typo in Step 11 HOT 1
- Typo in the Poisson equation discretization in Step 11 HOT 2
- No pressure gradient in step 12? HOT 2
- About equation 4 in step11 HOT 4
- Step 8 transpose equations typo
- definition of L1 norm on Step 9: 2D Laplace Equation HOT 2
- CD Derivation - Step 3
- Initialization error in Step 7 HOT 1
- cfdpython HOT 1
- Disappearing viscosity term in the discrete version of Poisson-pressure equation HOT 10
- Initialization error in Step 9 HOT 1
- Step 5: matplotlib error HOT 3
- Outdated dependencies HOT 1
- Lesson 14 build_up_b
- CFD Code Writing HOT 2
- Step #4 Initial Conditions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cfdpython.