mittinatten / freesasa

C-library for calculating Solvent Accessible Surface Areas
http://freesasa.github.io/
MIT License
103 stars 37 forks source link

Questions for understanding codes implementation #87

Closed zhongxiang117 closed 1 year ago

zhongxiang117 commented 1 year ago

Hi Mittinatten,

I am trying to understand the codes implementation via your writing from: http://freesasa.github.io/doxygen/Geometry.html, there are some questions that I feel confused,

1) For the law of cosine to calculate the angle of circle i that is buried due to circle j, should the angle be calculated by switching the subscript i and j in numerator? Please check on the attached image:

image

2) For the arc that exposed in slice, am I correct in my drawing picture? (Specifically only for that slice)

image

3) For the sum of arcs that exposed in each slice, looking at your codes, am I correct that the sum was performed on dash truncation in the space? (Still, please have a look on the attached picture in above)

I greatly appreciate for your help, thank you very much!

zhongxiang117 commented 1 year ago

Typo: in the first question in denominator, the square 2 should be '(prime).

mittinatten commented 1 year ago

Hi, sorry for the delayed response

  1. You are right, there is a typo in the documentation, the code uses alpha = acos((Ri_prime2 + dij * dij - Rj_prime2) / (2.0 * Ri_prime * dij));, i.e. there is a plus sign in front of d_ij. I will update the docs.
  2. The picture is not entirely correct, the delta is the distance between slices, not the distance between a slice and the center of the sphere. So the picture to the left is misleading, the one to the right is correct.
  3. I don't know what dash truncation is.
zhongxiang117 commented 1 year ago

Hi, thanks for your explanation, I guess now I know the codes implementation.

  1. Thanks for your update.
  2. The picture on the left only shows that slice, thanks for your clarification, now it makes more clear to me to understand the distance between the slices.
  3. I saw in your codes, there is a line: z = zi - Ri - 0.5 * delta; in file "sasa_lr.c" line 305, you can refer to here, so based on my question 2, the summarize is actually performed on the center of the slices, which is the meaning of the dash lines, am I correct?

Thank you again for your reply! -xiang

mittinatten commented 1 year ago

Ok, so the summation starts from the "bottom" along the z-axis, line 305 sets the initial value to zi - Ri - 0.5*delta as you noticed, which is one half delta outside the sphere, but line 307 adds 1 delta, so the first slice is tangent to the sphere. We also have delta = 2*Ri / n, which means we have 2/n slices on each side of the center. So you are right, each slice is centered on the dashes in your picture.

zhongxiang117 commented 1 year ago

Thank you for your reply and explanations. I am going to close this issue, thank you!