Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON!!!!!!! You have been tasked with simulating particle transport through a material as shown in Fig. 1. The particle is shot out and hits the

PYTHON!!!!!!!

image text in transcribedYou have been tasked with simulating particle transport through a material as shown in Fig. 1. The particle is shot out and hits the material. It then travels through the material and may get stopped after a certain distance or may travel all the way through the material. Different lengths that the particles are embedded in Particles being fired at material Particles that went through material unaffected Figure 1: Particles Moving Through a Material You are to perform a Monte Carlo analysis to determine how far a particle travels through various materials. Monte Carlo analysis uses random numbers to get an approximate answer to very hard problems. Usually a signi cant number of trials are conducted to obtain adequate statistics. For your convenience, a owchart is provided at the end of the exam. 1. You are to make a dictionary that, when given a material's name, will output the probability that the particle will travel through a half centimenter chunk of the material. The list of materials and their associated probabilities are given below in Table 1 Material Probability Material A 95% Material B 90% Material C 85% Material D 80% Material E 75% Table 1: Material List 2. At the beginning, N particles exist (here N=1e6). As it passes through a section, a uniformly random number between 0 and 1 is generated for each particle. Those particles that have their random number less than or equal to the probability (in decimal format) survive to go to the next slab. All others are absorbed and disappear from the population. This process continues until there are either no particles or until the remaining particles escape the material. You need to make a function that will generate and return the required number of random numbers. To generate a random number, you need to import the random library. The use of random.random() will generate a number between 0 and 1. 1 3. The length of the material is given as 20 cm. You should make a bin for every 0.5 cm through the material starting at 0 cm and ending at 20 cm inclusively. The rst bin represents that the particle didn't even move through one chunk, the second bin represents that the particle moved through the rst chunk but not the second, and so on. Meanwhile, the nal bin represents that the particle passed through the material completely. Using the function you made before, write a program (with the dictionary included) that when given the material's name will perform the simulation 1 million times and return two lists - one list representing the starting location of each bin/chunk and the other a list of lists, with each list in that list representing the number of particles that made it through those chunks for each material. Basically the last list is the pro le for each material. Therefore, there will be 41 position, and you need to store the number of particles that survive at each position for each material(A through E in alphabetical order). In addition to your code, provide a table with your results. There should columns and 41 row. The rst column is the position/chunk number, and the next columns should be the materials in alphabetical order. Using le output, save this information to the text le results.txt. Upload this le along with your Python code. 4. Your program must have at least one of each of the following concepts that were covered in the course: a. A list b. A for loop c. A dictionary d. Use of list comprehension e. Logical comparison f. A function g. Importing a library h. Use of writing to a text le

stopped after a certain distance or may travel all the way through the material Particles being fired at material Partides that went through material unaffected Different lengths that the particles are embedded in Figure 1: Particles Moving Through a Material You are to perform a Monte Carlo analysis to determine how far a particle travels through various materials. Monte Carlo analysis uses random numbers to get an approximate answer to very hard problems. Usually a significant number of trials are conducted to obtain adequate statistics. For your convenience, a flowchart is provided at the end of the exam 1. You are to make a dictionary that, when given a material's name, will output the probability that the particle will travel through a half centimenter chunk of the material. The list of materials and their associated probabilities are given below in Table 1 MaterialProbability Materia!A | 95% Material Bl 90% Material( 85% Material D | 80% Material 75% Table 1: Material List stopped after a certain distance or may travel all the way through the material Particles being fired at material Partides that went through material unaffected Different lengths that the particles are embedded in Figure 1: Particles Moving Through a Material You are to perform a Monte Carlo analysis to determine how far a particle travels through various materials. Monte Carlo analysis uses random numbers to get an approximate answer to very hard problems. Usually a significant number of trials are conducted to obtain adequate statistics. For your convenience, a flowchart is provided at the end of the exam 1. You are to make a dictionary that, when given a material's name, will output the probability that the particle will travel through a half centimenter chunk of the material. The list of materials and their associated probabilities are given below in Table 1 MaterialProbability Materia!A | 95% Material Bl 90% Material( 85% Material D | 80% Material 75% Table 1: Material List

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

Do you currently have a team agreement?

Answered: 1 week ago

Question

How will the members be held accountable?

Answered: 1 week ago