Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@JegerBroxterman
Copy link
Collaborator

Included reduced inertia and reduced projected inertia tensors. Changed the inertia tensor calculation by dividing by the total mass.

Copy link
Collaborator

@robjmcgibbon robjmcgibbon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of comments. Also could you please run the formatter?


# 3x3 inertia tensor
Itensor = (mass[:, None, None] * position[:, None:, None] * position[:, None]).sum(
Itensor = (mass[:, None, None]/mass.sum() * position[:, None:, None] * position[:, None]).sum(
Copy link
Collaborator

@robjmcgibbon robjmcgibbon Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing the units of the inertia tensor (not saying you shouldn't, I'm just curious as to why)? Do you know of anyone else who uses this property that will need to be informed of the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because of the convention of the inertia tensor in intrinsic alignment context. In general physics, people the inertia tensor as m*r^2 but in the context of intrinsic alignment, we usually divide by the total mass of the object. (see e.g. eq. 7,8 of https://arxiv.org/abs/2309.08605). I am only aware of Aniruddh currently working on IA and I already informed him.

)
return Itensor

def get_reduced_inertia_tensor(mass, position):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is quite a lot of duplicated code shared with get_inertia_tensor. Could you combine these functions by passing a keyword argument, e.g. get_inertia_tensor(mass, position, reduce=False)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will make the changes

Itensor = np.concatenate([np.diag(Itensor), Itensor[np.triu_indices(3, 1)]])
return Itensor

def get_reduced_projected_inertia_tensor(mass, position, axis):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also pass a keyword argument to get_projected_inertia_tensor

)
Itensor = Itensor.sum(axis=0)
Itensor = (
np.array((Itensor[0, 0], Itensor[1, 1], Itensor[0, 1]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to multiply by units here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reduced projected inertia tensor is unitless

@robjmcgibbon robjmcgibbon merged commit 4f1b550 into master Dec 5, 2023
@robjmcgibbon robjmcgibbon deleted the inertia_tensor branch December 5, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants