Question: please the script should be on c++ and Matlab Problem 4 [50 Using the generated positions, calculate and print the total potential energy of the
please the script should be on c++ and Matlab
Problem 4 [50 Using the generated positions, calculate and print the total potential energy of the system An easily implemented (but not the most efficient) way of calculating this energy is , total_ where is the potential energy of the ith particle. This quantity is calculated by considering all of the potential interactions the ith particle has with every other particle BC (dy)12)d, where dy is the distance between the ith and jth particle and A, B, and C are constants. Use A-1, B 2, C-10 Approach: Iterate over each body (i). Within that loop, iterate over every other body (j) Calculate the distance between i and J (dis), Use that distance to calculate . Sum all those for the ith body to find ,' Sum all those to find total. Note that a particle cannot interact with itself, so i-j should be skipped Problem 4 [50 Using the generated positions, calculate and print the total potential energy of the system An easily implemented (but not the most efficient) way of calculating this energy is , total_ where is the potential energy of the ith particle. This quantity is calculated by considering all of the potential interactions the ith particle has with every other particle BC (dy)12)d, where dy is the distance between the ith and jth particle and A, B, and C are constants. Use A-1, B 2, C-10 Approach: Iterate over each body (i). Within that loop, iterate over every other body (j) Calculate the distance between i and J (dis), Use that distance to calculate . Sum all those for the ith body to find ,' Sum all those to find total. Note that a particle cannot interact with itself, so i-j should be skipped
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
