Can I use open-source code for a simulation for my research? I am working on a paper and I found open-source code that I could use for running a simulation. Should I write my own code for that simulation? Will it be enough if I refer to the code in my citations/references section?
Yes, open-source code can be used for research if it is cited everywhere you use results from it. You may first like to verify that the code is indeed open-source by verifying that the license is one of these: https://opensource.org/licenses

This should be listed clearly on the website/repository/license/readme file. If this is not available, try contacting the author to verify that it is indeed open source.

Certain licenses additionally allow you to freely modify the code for your specific purpose; the link above contains details about this.