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 over array indices (which appear in the program as i and j) into vectorized operations.

You will hopefully find the 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

  • 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 (; for the vectorized version, it is far more natural to use the 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 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 that I can run against the code in

Attachment:- fluid

Reference no: EM131098009

Describe how it applies to the realm of data communication

Write one to two paragraphs on each topic below, and describe how it applies to the realm of data communication. Also discuss what type of damage these computer infections c

What is the maximum directly addressable memory capacity

SCO 104 Computer Organizations and Architecture I- What is the maximum directly addressable memory capacity (in bytes)? How many bits are needed for the program counter and th

Find the total cost of the first hundred units

A company's marginal cost function is MC(x)(given below), where x is the number of units. Find the total cost of the first hundred units (x = 0to x = 100).(Round your answer

Implement a hash algorithm

Create a flowchart to show the processing that will take place for the implementation of a hash structure - Present the flowchart for the hash function operation separately.

Compare and contrast the two frameworks.

Give a brief description of cognition and its relationship to four dominant cognitive frameworks for HCI and Interaction Design. Provide full accounts of two of these framew

How many bits are needed for the pointer?

take a fixed partitioning scheme with equal-size partitions of 2^16 bytes and a total main memory size of 2^24 bytes. A process table is maintained that includes a pointer t

What might have happened if the bug had not been caught

My first programming job in 1977 was to convert a set of application systems from one version of COBOL to another version of COBOL for the government of Prince Edward Island

How many bits are there in the physical address

Consider a logical address pace of 64 pages of 1024 bytes each, mapped onto a physical memory of 32 frames of 1024 bytes each. How many bits are there in the logical address?


Write a Review

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