Diffraction applet - how to make one in one day

Click For Summary

Discussion Overview

The discussion revolves around creating a diffraction applet within a tight timeframe, focusing on the technical challenges and programming languages suitable for the task. Participants share their experiences and suggest various tools and approaches for simulating diffraction, particularly in Python and other programming environments.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant expresses urgency in creating a diffraction applet in one day, despite having limited programming experience.
  • Another participant doubts the feasibility of completing the applet in one day, even for experienced programmers.
  • A later reply clarifies that the original poster technically has three days but feels overwhelmed and seeks help.
  • Suggestions include using Python with libraries like scipy and xrt, though concerns about technical challenges are noted.
  • One participant recommends JavaScript for web-based simulations, while acknowledging the original poster's comfort with Python.
  • Another participant proposes using the Processing IDE, suggesting it could be done in about 50 lines of code and is beginner-friendly.
  • Alternative options mentioned include the Pythonista app for iOS and a Processing app for mobile devices.
  • A suggestion is made to use Mathematica's Manipulate feature for a professional look, referencing the Wolfram Demonstration Project.

Areas of Agreement / Disagreement

Participants express varying opinions on the feasibility of completing the applet in one day, with some doubting it is possible while others provide potential solutions. There is no consensus on the best programming approach, as multiple languages and tools are suggested.

Contextual Notes

Participants highlight limitations related to the original poster's programming experience and the time constraints for the project. The discussion reflects uncertainty about the best tools and methods for achieving the desired simulation.

Who May Find This Useful

This discussion may be useful for individuals interested in programming simulations, particularly in the context of physics and diffraction, as well as those seeking advice on rapid development under tight deadlines.

erisedk
Messages
372
Reaction score
7
I'm not sure which forum this would go into, but I'm desperate so I'll just post here.

So, I have exactly one day to make a diffraction applet. I know a lot about diffraction, nothing about making applets. I've programmed a tiny bit in python, but never made an actual project before.

Here's an email describing what I need to make

HI erisedk, Thanks for the questions:

Is the simulation supposed to include only single slit diffraction or both single slit and multiple slit (diffraction grating)?

Ans: only multiple slits (say 10, for concreteness). And I wouldn’t worry about the single-slit envelope, since the grating slit width is usually small enough that the light diffracts into the forward half-plane.

Should it model only a single wavelength of light or should you be able to model any number of wavelengths, including white light?

Ans: Just one wavelength. It will be for light, but you don’t need to constrain yourself to that. In particular, the applet I was looking at was http://falstad.com/ripple/ Setup: plane wave 1 plane source, 1 frequency Edit walls, and then put in a periodic grating (at least on my computer there’s a location indicator is the lower left — the slits must be equally spaced and of equal size). Note: Changing the resolution erases any modifications. 2nd note: if you can figure out what the coding for the import file is (just put some walls in and look at the export text), you could do the whole thing by numbers, and it would be very easy to modify to find the best setting. (I have no idea what the second part of the answer means)

Are there any very specific controls that you would like to see, that are not commonly available in most applets?

Ans: For this I’d be happy with a video (i.e., no controls). Though if there was to be any controls, then controlling the wavelength (to show how different colors diffract in different directions) would be good.

These are the details. I'd be so grateful for help, especially, step by step instructions.
 
Technology news on Phys.org
erisedk said:
So, I have exactly one day to make a diffraction applet. I know a lot about diffraction, nothing about making applets. I've programmed a tiny bit in python, but never made an actual project before.
In one day? Forget about it. Even if you were a seasoned programmer, I would be surprised if you could pull that off in one day.
 
DrClaude said:
In one day? Forget about it. Even if you were a seasoned programmer, I would be surprised if you could pull that off in one day.

Well, I technically had 3 days to do it. But I couldn't figure out how to get started really. I downloaded scipy and xrt for python and read a bit. I learned about diffraction. But I feel so technically challenged. I could at the most turn it in on Sunday I think. I'm willing to spend all my time on it (like literally, no sleep no eat etc). I just need to get it done. Please help!

Also, I think that the tag shouldn't be java, it should be python.
 
erisedk said:
Well, I technically had 3 days to do it. But I couldn't figure out how to get started really. I downloaded scipy and xrt for python and read a bit. I learned about diffraction. But I feel so technically challenged. I could at the most turn it in on Sunday I think. I'm willing to spend all my time on it (like literally, no sleep no eat etc). I just need to get it done. Please help!

Also, I think that the tag shouldn't be java, it should be python.

If you need your simulation to run in a web browser, I would think JavaScript is the sensible option.

However, due to time constraints and as I understand it, Python is the language you are most comfortable with, it is possible to make do. The options I think you have are to write your simulation in python and use a python to java compiler such as "pyjamas", or use "empythoned" to run CPython in your browser.

Take a look at PyGame as an environment to house your physics simulation.
 
I would use processing IDE for this. Download it look at the tutorials on the site and go for it. In general, I'd guess it would be about 50 lines or less to do. Processing comes with examples, has the graphics built in. You'd be using Java but they provide the wrapper. All you to provide are two methods setup which runs once and draw which is called every sixtieth of a second. Processing geared toward beginners and graphic artists who want to code.

https://processing.org/examples/reflection1.html

More examples and animations here

https://processing.org/examples/

Processing does have a python/jython mode that works in a similar fashion with examples too.
 
If you have an iPhone or iPad then there's the pythonista app to consider at around $5 which works in a similar fashion to processing. You'd have to hand in your phone to get a grade haha or you could video record the app running.

There's also a processing app on both iPhone and android too. On iPhone it's JavaScript based and on android it's Java based.
 
Would look nice and professional encapsulated in a Mathematica Manipulate. Are you familiar with the Wolfram Demonstration Project? You could download one that is similar and just edit it for your needs.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
9
Views
4K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 26 ·
Replies
26
Views
11K
  • · Replies 11 ·
Replies
11
Views
5K