Hi,
You can start with the project file and matlab file in this other discussion:
https://optiwave.com/forums/topic/system-power-penalty-and-link-margin/#post-10906
In the Matlab file, I calculated the effective area of the mode, which is a common modal measure in nonlinear applications. Depending on your definition of modal diameter, you will just need to change the lines that I wrote for calculating the effective area.
I hope this helps!