FormingWorlds / PROTEUS

Coupled atmosphere-interior framework to simulate the temporal evolution of rocky planets.
https://proteus-code.readthedocs.io
Apache License 2.0
10 stars 1 forks source link

Optimise spider.py #65

Closed nichollsh closed 4 months ago

nichollsh commented 5 months ago

Currently, spider.py makes a lot of file I/O operations which slows down the model increasingly as the simulation progresses. This is because it reads-in all of the prior .json files when doing some of the spider-related stuff. It reads them in several times, depending on the variables being accessed and the calculations being performed, meaning that the performance drops off quickly (super-linearly) with model runtime. It would be a lot faster if they were just read-in once, and then analysed together.

nichollsh commented 4 months ago

Related to this... Some of the plotting functions are also very slow. I've just re-written cpl_global.py, which has led to a performance improvement of 25x. Making the plot on a near-completed run used to take ~2 mins, but now takes ~4 seconds. This was done by avoiding the use of SPIDER's json files, and just accessing data from the csv file that PROTEUS keeps.

nichollsh commented 4 months ago

And on this topic, it would probably be optimal to re-frame the way that the helpfile.csv is used. Why constantly save and load the file, when it could just be passed around as a variable? Saving it each iteration makes sense, but loading it again does not.