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

  Explain a mechanism by which an operating system can

describe a mechanism by which an operating system can enforce limited transfer of capabilities.that is process a might

  What is coming singularity and exponential technology

what is coming singularity and exponential technology

  Designing the calculator program

Develop a calculator program which will subtract, add, multiply, or divide two numbers input given by a user. If user selects division, do not permit the user to divide by 0

  Write a program to simulate the authentication process

The user would enter 23113 instead of 12345. This doesn't divulge the password even if an attacker intercepts the entry because 23113 could correspond to other PIN numbers.

  Give a detailed rational for choosing bit-mapped

For each of the following give a detailed rational for choosing bit-mapped or vector graphics when they are used in a web based application.

  How the project management life cycle be efficient

How the Project Management Life Cycle be efficient.

  Create a .plan file using pico/nano

Create a .plan file using PICO/NANO

  Make an efficient object-oriented java application

while a house is chosen by the roommates, the user will give information for it. To allow extensibility, a house object can be created with no information available, address of the house only or the address of the house, monthly rent and security d..

  Prove the following property of boolean algebra

prove the following property of Boolean algebra . give a reason for each step !!

  Prove correctness for following

Prove correctness for following

  Write program that computes the cost of a long distance call

Write program that computes the cost of a long distance call

  Calculate matrix-vector product using mpi processes

Implement a parallel algorithm that calculates matrix-vector product using MPI processes, What is the cause of the difference? What are the advantages and disadvantages of two approaches?

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