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

  Analyze the changes in 4g technology since the printing of

there are a number of cellular phone companies each serving their own unique geographical areas. likewise they each may

  Describing the ttl

Support that a security-aware caching resolver accepts a DNS RRset at time t0 with signatures on it which will expire at time t1 (where t0

  Write down a shell script to send a customized

Write down a shell script to send a customized mail message to the users listed on the command line by login (user) name, only if they are currently logged on. If no users are listed on the command line, an error message should be printed.

  Questionyou have been assigned task of computing the sum of

questionyou have been assigned task of computing the sum of 1000 four-digit numbers as rapidly as possible. you hold in

  Considering the mistakes made by the police department and

perhaps one of the most famous and publicized crime stories in contemporary america occurred in june of 1994 when the

  Develop a plan on how to support a business

Develop a plan on how to support a business need with software, this software will have data points that we need to map.

  Calculate gate length of my laptop cpu using its clock speed

How can I calculate gate length of my laptop cpu using its clock speed rate like i7- 2.3 Ghz? that is all i got to do the calculations. of course it would be ok to have some reasonable assumptions.

  Determining the counterexample

Determine a counterexample for following algorithm on the basis of greedy strategy: Choose the largest subset for cover, and then delete all its elements from the universal set.

  Draw a design of a cloud based system for storing

SIT113 - Cloud Computing and Virtualisation Trimester Assignment. Draw a design of a cloud based system for storing, accessing, updating, processing, securing, sharing, and publishing S-mart data and information

  Write a program that can be used to convert meters

Write a program that can be used to convert meters to feet and inches. Allow the user to enter a metric meter value in a method.

  What do you think are the sources of the information jim

although the customer loyalty project at petries electronics had gone slowly at first the past few weeks had been fast

  Questiona pretty print program takes a program that could

questiona pretty print program takes a program that could not be indented in any particular way and produces a copy

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