Find that a successful vectorized implementation is faster

Assignment Help Computer Engineering
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

Reference no: EM131098009

Questions Cloud

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?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Consider this scenario mr brown and mr green have argued

consider this scenario mr. brown and mr. green have argued several times about which one of them has the slowest horse.

  Perform the operations involving 2''s complement numbers

Perform the subsequent operations involving eight-bit 2's complement numbers and indicated whether overflow occurs.

  Prove inversion are removed

Suppose we exchange elements a[i] and a[i+k] which were out of order.  Prove at least 1 and at most 2k-1 inversion are removed.

  Pros and cons of application software in business

Operating system software for your personal PC: define What are the differences among Windows OSs

  How the smallest word is at offset 0000

Sort all the words in memory that could be considred to be decimal ASCII-coded numbers. An ASCII-coded word can vary from 3030h (00d) to 3939h (99d). Sort the ASCII words so that the smallest word is at offset 0000.

  Recognize and explain a future information technology which

you are the new chief information officer for acme widgets. the president of the company recently asked you what you

  How to produce a wired and wireless network plan

How to produce a wired and wireless network plan

  Find out another design pattern for web based development

There are other design patterns that could be directly applicable to PHP programming, or web programming in general.

  Valuing the health care

Find the best way in order to leverage value from the health IM / IT investments in today’s health care environment. Give some specific examples in order to support your response.

  Does the bureau of labor statistics provide any comments or

you are a staff writer at it flash magazine a popular online newsletter aimed at it professionals. your editor has

  Discuss pros of using automated testing tools

Why do so many in-house applications never get finished.

  Conditional jump statements

Assume for each part of this problem that the EAX register contains 00 00 00 4F and the doubleword referenced by value contains FF FF FF 38. Determine whether each of the conditional jump statements causes a jump to dest.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd