Reference no: EM131098009
E19: Numerical Methods for Engineering Applications Spring 2016 - HOMEWORK 13
Vectorized fluid simulation code
Download the (slow, explicitly looped) fluid simulation code from the course website. It contains a complete Python port of Jos Stam's method. Your job is to convert every explicit loop in Fluid.py over array indices (which appear in the program as i and j) into vectorized operations.
You will hopefully find the indexing_strategies.py script useful for this, as it gives a few hints about useful techniques. Here are some other miscellaneous tips for converting the various functions in Fluid.py:
- For set_bnd, each individual border (top/bottom/left/right) can be handled in one assignment statement.
- The looped version of solve uses the Gauss-Seidel method (https://en.wikipedia.org/wiki/Gauss-Seidel_method); for the vectorized version, it is far more natural to use the Jacobi method (https://en.wikipedia.org/wiki/Jacobi_method) instead. The former updates the solution element-by-element, in-place, whereas the latter updates the entire solution at once. You can keep the outermost loop over k.
- For advect, you can let i and j be arrays created from numpy.meshgrid. The max and min calls will have to be replaced with the functions numpy.maximum and numpy.minimum, respectively. The other subtlety here is that i0 and j0 should be arrays of integer type (e.g., i0 = y.astype(int)).
- For project, looking at dx and dy in the indexing_strategies.py script may be helpful.
- It is best to vectorize one function at a time, and make sure you get identical results for each change you make (or near-identical, for Jacobi iteration vs. Gauss-Seidel).
You will find that a successful vectorized implementation is vastly faster than one with explicit loops. On my laptop, for N = 32, the looped code takes about 130 ms per update vs. 5 ms for vectorized. For N = 128, the respective runtimes are 2000 ms vs. 20 ms.
Submit your vectorized code via Moodle (with your name at the top of the file). Please do not change the interfaces of any of the functions - I want a drop-in replacement for Fluid.py that I can run against the code in sim.py.
Attachment:- fluid sim.zip
Explain how you might educate parents on implementing
: Consider strategies for mitigating each issue that promote good self-perception, positive behavior, and mental wellness in the age group you selected. Reflect on how you might educate parents on implementing these strategies with their children.
|
Thresholds of a data-communications system
: A manufacturer of power meters, which are used to regulate energy thresholds of a data-communications system, claims that when its production process is operating correctly, only 10% of the power meters will be defective.
|
Develop a single dfd that shows processing for all events
: Develop DFD fragments for all of the events not documented in Figure 6-12. Develop a single DFD that shows processing for all events, using one process for each subsystem and showing all needed data stores.
|
Mutation develop breast cancer
: In the general population, one woman in ten will develop breast cancer. Research has shown that 1 woman in 600 carries a mutation of the BRCA gene. Seven out of 10 women with this mutation develop breast cancer.
|
Find that a successful vectorized implementation is faster
: E19: Numerical Methods for Engineering Applications Spring 2016 - HOMEWORK 13. You will find that a successful vectorized implementation is vastly faster than one with explicit loops. On my laptop, for N = 32, the looped code takes about 130 ms per..
|
Explain how the health concern is linked to health inequity
: Explain how you would evaluate the effectiveness of the nursing action plan created in part D. Identify the measurable tools necessary to perform the evaluation.
|
Assisted reproductive technology
: A study found that 38%of the assisted reproductive technology(ART) cycles resulted in pregnancies. Twenty-six percent of the ART pregnancies resulted in multiple births.
|
Develop a class implementation for the mincost-flow problem
: Show that the mincost-maxflow problem reduces to the transportation problem with just V extra vertices and edges by using a construction similar to the one used in the proof of Property 22.16.
|
Probability at least one is allergic to pollen
: If two people are randomly selected, what is the probability both are allergic to pollen? What is the probability at least one is allergic to pollen?
|