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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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