Exploring the magic and limitations of ChatGPT in generating Python code for acoustic design - Day 2
- Su
- Apr 17, 2023
- 2 min read
Updated: Apr 18, 2023
Finding incident rays and energy distribution on a reflector from an omni-directional sound source

On Day 1, I successfully created an omni-directional source using ChatGPT. In room acoustic design, it's important to determine how much energy from a source is projected onto a reflector. To calculate this, I need to find out the number of rays from the omni-directional source that intersect with the reflector. Can ChatGPT assist me again by generating Python code for this task?
I provided detailed instructions to ChatGPT 4, and it generated the code below in just 1 second. Unfortunately, the code turned out to be a disaster. It contained around 10 errors in just 30 lines of code.
One major error is to do the function for finding the intersection between a line and a brep. Although the function "CurveBrepIntersect" is correct to use for this task (as seen in line 12 of the code), ChatGPT 4 did not understand the syntax of this function. I provided the syntax of the function to ChatGPT and asked it to revise the code accordingly, but the result was unsuccessful. It appears that ChatGPT cannot learn directly from dialogue.
After spending a considerable amount of time fixing the bugs in the code generated by ChatGPT, I ended up rewriting the entire script and was able to obtain the results shown in the picture. The reflector in this example received 5.5% of the energy from the source. During this process, ChatGPT was helpful in providing some information, such as how to format data as a percentage with one decimal point.
The code below was generated by ChatGPT 4, but it contains many errors.




Comments