nuclear shielding simulator

justinjames92

New Member
Joined
May 2, 2011
Messages
5
As an illustration, suppose that a slab of material is used to shield a nuclear reactor and that a
particle entering the shield follows a random path by moving forward, backward, left, or right with
equal likelihood, in jumps of one unit. A change of direction is interpreted as a collision with an
atom in this shield. Suppose that after 10 such collisions, the particle's energy is dissipated and that it
dies within the shield, provided that it has not already passed back inside the reactor or outside
through the shield. A program is to be written to simulate particles entering this shield and to
determine what percentage of them gets through it.
Think of the metal wall that is supposed to keep the high-energy particles contained as being
4 units thick and boundless in the horizontal direction. Divide up the cross-sectional view of the wall
as occupying a region 4 rows and, say, 20 columns. Use the coordinates (I, J) for (row, column) with
(0, 0) representing cell Al. Assume each particle starts its random motion into the wall in the top row
(I = 0) and column H (J = 7) of the spreadsheet (the metal wall begins at the second row and extends
to include the fifth row). Make a random number generator which returns one of the integers 1, 2, 3,
or 4, corresponding to down, up, left and right...the four random directions the particle can bounce.
Use Select Case and Offset to move the particle once its random number is generated. Get
another random number and repeat the movement. Continue this in a loop until either 10 numbers
have been generated and the particle decays or it escapes (made it to the 6th row down) whereby an
"out" should be placed in the cell where it left the metal wall. Put this entire process of a loop that
will repeat for 100 particles.
Animate the process by having the cell in which the particle is be colored red. Clear the cell
if the particle decays or if the particle escapes. Call a "delay" subprogram to slow down the action to
be visible but fast. Oftentimes more than one particle escapes the metal at the same column. If this
happens, have the active cell move down one row and then print "out-. Include a counter as to how
many of the 100 particles make it through the shielding wall.



any help???
 
i tried using activate instead of using select and it didnt make a difference this is the code i have so far

Sub random()
Dim i As Integer
Dim n As Integer
Dim p As Integer


Range("h2").Select
i = ActiveCell.Value
ActiveCell.Value = Clear


p = 2
If p = 2 Then

ActiveCell.Offset(1, 0).Select

ActiveCell.Value = i
ActiveCell.Value = Clear

End If

n = Int(Rnd * 4)

Select Case n
Case Is = 4
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = i
ActiveCell.Select


Case Is = 3
ActiveCell.Offset(0, -1).Select
ActiveCell.Value = i
ActiveCell.Select



Case Is = 2
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = i
ActiveCell.Select


Case Is = 1
ActiveCell.Offset(-1, 0).Select
ActiveCell.Value = i
ActiveCell.Select




End Select








End Sub
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
i have made the changes to the code inorder to get the first part done



now each particles moves down once into the particle and after that first movement down can move a maximum of ten times (collisions) within the shield or it will be destroyed due to lack of energy...what would i do for the code so that each particle moves down once and then the movement of the particle is solely based on the random number generator 1 = down 2 = up 3 = left 4 = right


also the particle can leave the shield which i would have to make a code inorder to count how many have left the shield is from a2:t5


next 100 particles must go throught the entire system
 
Upvote 0
This info (and the other nb. stuff) previous is probably key, or the whole point of your endeavor is moot.
Forward
Back
Left
Right
Up
Down.
Your time and energy will be wasted by not initially addressing the logic. Do you want a video game or a real solution? I'm not sure that we do homework but we do help. The problem is displaying the output. The rest is not the hard part. I suggest you stop using select and activate (wirh some exceptions) in your code. Specify. Use VBA Range and/or Cell designations. HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,876
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top