Diffraction applet - how to make one in one day

In summary: 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.In summary, you need to learn about diffraction before you can make an applet. You only have one day to do it, and you're not sure if it should be in JavaScript or Python. You would like to see controls, and the tag should be either
  • #1
erisedk
374
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
  • #2
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.
 
  • #3
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.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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.
 
  • #7
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.
 

Related to Diffraction applet - how to make one in one day

1. How can I make a diffraction applet in one day?

Making a diffraction applet in one day requires a good understanding of programming and the principles of diffraction. You will need to have experience with coding languages such as Java or HTML, as well as knowledge of diffraction concepts such as Huygens' principle and the diffraction grating equation. With the right skills and dedication, it is possible to create a basic diffraction applet in one day.

2. What tools or software do I need to create a diffraction applet?

In order to create a diffraction applet, you will need a programming environment or software that supports the coding language you plan to use. Some popular options include Java applet development tools such as Eclipse or NetBeans, or web development tools such as Adobe Dreamweaver or Notepad++. You may also need image editing software to design the graphics for your applet.

3. Can I use existing code or templates to make my diffraction applet?

Yes, you can use existing code or templates to create your diffraction applet. However, it is important to make sure that you understand the code and can modify it to fit your specific needs. It is also important to give credit to the original source if you use their code. Using templates or existing code can save you time, but it is still important to have a good understanding of the principles behind the code.

4. Are there any online resources or tutorials for creating a diffraction applet?

Yes, there are many online resources and tutorials available for creating a diffraction applet. A simple internet search can bring up a variety of options, including step-by-step tutorials, video guides, and forums where you can ask questions and get help from other developers. It is always a good idea to do some research and find a resource that best fits your learning style.

5. Can I test my diffraction applet before publishing it?

Yes, it is highly recommended to test your diffraction applet before publishing it. This will allow you to identify and fix any errors or bugs, and make sure that your applet is functioning as intended. You can test your applet by running it on a local server or by using online testing tools. It is important to thoroughly test your applet to ensure a smooth and error-free user experience.

Similar threads

Replies
5
Views
932
  • Advanced Physics Homework Help
Replies
1
Views
981
Replies
5
Views
7K
  • Introductory Physics Homework Help
Replies
5
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Advanced Physics Homework Help
Replies
2
Views
1K
Replies
1
Views
4K
  • Introductory Physics Homework Help
Replies
4
Views
2K
Back
Top