-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfeedback_class.py
42 lines (37 loc) · 1.21 KB
/
feedback_class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Feedback class
"""
from amuse.units import units
from amuse.units.trigo import sin, cos, arccos, arctan
def stellar_feedback(gas_, stars):
# Extremely simplified stellar feedback onto gas
gas = gas_.copy()
mass_cutoff = 5 | units.MSun
rmax = 1000 | units.AU
massive_stars = stars.select(
lambda m:
m >= mass_cutoff,
["mass"]
)
for i, star in enumerate(massive_stars):
gas.position -= star.position
gas.dist = gas.position.lengths()
gas = gas.sorted_by_attribute("dist")
gas_near_star = gas.select(
lambda r:
r < rmax,
["dist"]
)
theta = arccos(gas_near_star.z/gas_near_star.dist)
phi = arctan(gas_near_star.y / gas_near_star.x)
# Something related to energy
# (Slow) solar wind is about 400 km/s
# (1 | units.AU) / self.feedback_timestep
base_velocity = (400 | units.kms)
gas_near_star.vx += sin(theta) * cos(phi) * base_velocity
gas_near_star.vy += sin(theta) * sin(phi) * base_velocity
gas_near_star.vz += cos(theta) * base_velocity
gas.position += star.position
return gas