Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There is only one part in this programming project. You will write a Python program that implements an oversimplified simulation of diffusion in a 2-D

image text in transcribedimage text in transcribedimage text in transcribed

There is only one part in this programming project. You will write a Python program that implements an oversimplified simulation of diffusion in a 2-D square grid. Suppose we have a 10 x 10 grid, implemented as a 2-D array of floating point numbers, with 10 rows and 10 columns. grid(i, j) is the grid point at row i, column j. A chemical is injected into the grid, from several sources positioned in the grid. Each data point grid(i, j) represents the current concentration of the chemical. If a source is positioned at grid(i,j), then the concentration of the chemical at grid(i,j) is a constant. From each grid point, the chemical will slowly diffuse into its 4 nearest neighbors, according to the following equation: new grid[ (i,j)]-0.5* cur grid[(i,j)] + .125* (sum of 4 nearest neighbors of cur grid[ (i,j)]) Note: The points on the boundaries of the grid are not updated. The grid is always square. The program first prompts the user to enter the name of an input file. The input file contains the initial parameters for the diffusion simulation. The file format is: Number of simulation steps Width of grid Initial concentration Number of sources Row number of source 1 Row number of source 2column number of source 2 Row number of source 3column number of source 3 Row number of source 4column number of source 4 Etc... data of source 1 data of source 2 data of source 3 data of source 4 column number of source 1 Two sample files, in1.txt and in2.txt, are presented next (you can make your own, of course). You will need to create these files for testing your program. There is only one part in this programming project. You will write a Python program that implements an oversimplified simulation of diffusion in a 2-D square grid. Suppose we have a 10 x 10 grid, implemented as a 2-D array of floating point numbers, with 10 rows and 10 columns. grid(i, j) is the grid point at row i, column j. A chemical is injected into the grid, from several sources positioned in the grid. Each data point grid(i, j) represents the current concentration of the chemical. If a source is positioned at grid(i,j), then the concentration of the chemical at grid(i,j) is a constant. From each grid point, the chemical will slowly diffuse into its 4 nearest neighbors, according to the following equation: new grid[ (i,j)]-0.5* cur grid[(i,j)] + .125* (sum of 4 nearest neighbors of cur grid[ (i,j)]) Note: The points on the boundaries of the grid are not updated. The grid is always square. The program first prompts the user to enter the name of an input file. The input file contains the initial parameters for the diffusion simulation. The file format is: Number of simulation steps Width of grid Initial concentration Number of sources Row number of source 1 Row number of source 2column number of source 2 Row number of source 3column number of source 3 Row number of source 4column number of source 4 Etc... data of source 1 data of source 2 data of source 3 data of source 4 column number of source 1 Two sample files, in1.txt and in2.txt, are presented next (you can make your own, of course). You will need to create these files for testing your program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago

Question

5. Arranging for the training facility and room.

Answered: 1 week ago