Simulated optics experiment/Simulator: Difference between revisions

→‎Task description: Added RATFOR as a ref implementation.
(Added ratfor.)
(→‎Task description: Added RATFOR as a ref implementation.)
Line 17:
In this task you should write the program or set of programs that simulate the experimental apparatus, so generating raw data. The ''[[Simulated optics experiment/Data analysis]]'' task handles analysis of the raw data. There should be no need for the simulator and the data analysis to be in the same programming language. Therefore any implementation of the data analysis can be used to check your implementation of the simulator.
 
Write simulations of the following experimental devices. The descriptions may seem complicated, but the [[#ObjectIcon|Object Icon]] and, [[#Python|Python]], and [[#RATFOR|RATFOR]] examples can serve as references. The formerRATFOR is acertainly littlethe simplersimplest, andbut isthe notObject fullIcon may seem more familiar to "object oriented" programmers. The two are similar. The Python reformulates some calculations as Gibbs vectors (the "arrow" kind of strangevector), and runs as multiple Iconismsprocesses.
 
* A ''light source'', which occasionally emits two pulses of [[wp:Plane_of_polarization|plane-polarized light]], one towards the left, the other towards the right. Both pulses have an amplitude of 1. About half the time the pulses are polarized, respectively, at an angle of 0° on the left and 90° on the right. The rest of the time the angles are reversed: 90° on the left, 0° on the right. A random number generator should be used to select between the two settings. If the 0° angle is on the left, then a "0" should be recorded in a log. Otherwise a "1" is recorded.
Line 29:
* On the right, the first angle is 22.5° and the second is 67.5°.
 
The simulation is run by having the light source emit some number of pulses and letting the other devices do their work. How you arrange this to work is up to you. The [[#Python|Python]] example, for instance, runs each device as a separate process, connected to each other by queues. But you can instead have, for instance, an event loop, coroutines, etc.--or even just ordinary, procedural calculation of the numbers. The last method is simplest, and perfectly correct. It is what the [[#ObjectIcon|Object Icon]] exampleand does[[#RATFOR|RATFOR]] examples do. However, surely all the methods have their place in the world of simulations.
 
The program must output its "raw data" results in the format shown here by example:
1,448

edits