- #1
Sai Maurice
- 10
- 0
- Homework Statement
- The goal is to create a 2d array of Gibbs free energy of a copper-nickel solution as a function of temperature and composition in percent nickel, G(T,X). Additional requirements are based on time, where running of this code cannot take more than a few seconds.
- Relevant Equations
- G(T,X) = (1-X)*Gcu(T) + X*Gni(T)
Where:
T = a 1001 member array of temperatures in kelvin
X = a 101 member array of values for percent composition of nickel from 0 to 1
Gcu(T) = known values for the Gibbs free energy of copper at a given temperature T
Gni(T) = known values for the Gibbs free energy of nickel at a given temperature T
The method I employed was based on a nested loop. I ran into two issues with this approach
1. The code took way too long to run, easily going for over 7 minutes.
2. In the end, it didn't even completely work, due to the "index exceeding the array length". This confuses me
For the relevant sections, my code looks like the following:
How do I populate this 1001x101 2d array without relying on loops? Why am I exceeding the array length? Thank you for the feedback
1. The code took way too long to run, easily going for over 7 minutes.
2. In the end, it didn't even completely work, due to the "index exceeding the array length". This confuses me
For the relevant sections, my code looks like the following:
How do I populate this 1001x101 2d array without relying on loops? Why am I exceeding the array length? Thank you for the feedback