[ambipi] Adding calculation code for grid