1
2
3 """
4 Module for calculating mass loss structures as a function of radius.
5
6 Author: R. Lombaert
7
8 """
9
10 import numpy as np
11 from scipy.interpolate import InterpolatedUnivariateSpline as spline1d
12 from astropy import constants as cst
13 from astropy import units as u
14
15 from cc.modeling.profilers import Profiler
16
17
18
20
21 '''
22 Step function for the mass-loss rate.
23
24 When used for the dust mass-loss rate, requires the inner radius of the
25 dust shell to be given as r0.
26
27 Can be used also for the gas mass-loss rate with a step anywhere in the wind
28 This is not a smooth transition.
29
30 At r < r0: rate_inner, at r >= r0: rate.
31
32 @param r: r grid (can be array or float)
33 @type r: array/float
34 @param rate: The dust mass-loss rate from r0 onward
35 @type rate: float
36 @param r0: The dust condensation radius
37 @type r0: float
38
39 @keyword rate_inner: The mass-loss rate in the inner region at r<r0. Default
40 typically used for the dust mass-loss rate, with r0 the
41 condensation radius.
42
43 (default: 0.0)
44 @type rate_inner: float
45
46 @return: The dust mass-loss rate profile as a function of r
47 @rtype: array
48
49 '''
50
51 return Profiler.step(r,0,rate,r0)
52
53
54
55 -class Mdot(Profiler.Profiler):
56
57 '''
58 An interface for the mass-loss rate profile as a function of radius.
59
60 '''
61
64
65 '''
66 Create an instance of the Mdot() class. Requires a radial grid, a
67 function, and its arguments.
68
69 Default is a constant mass-loss rate, in which case mdot must be given
70 in Msun/yr.
71
72 @param r: The radial points (cm)
73 @type r: array
74 @keyword func: The function for calculating the density profile.
75
76 (default: dens_mdot)
77 @type func: func
78 @keyword dfunc: The function that describes the derivative of the
79 profile with respect to r. Can be given as an interp1d
80 object. If None, a generic central difference is taken
81 and interpolated.
82
83 (default: None)
84 @type dfunc: function/interp1d object
85 @keyword order: Order of the spline interpolation. Default is cubic.
86
87 (default: 3)
88 @type order: int
89
90 @keyword args: Additional parameters passed to the functions when eval
91 or diff are called.
92
93 (default: [])
94 @type args: tuple
95 @keyword kwargs: Additional keywords passed to the functions when eval
96 or diff are called.
97
98 (default: {})
99 @type kwargs: dict
100
101 '''
102
103 super(Mdot, self).__init__(r,func=func,dfunc=dfunc,order=order,\
104 *args,**kwargs)
105
106 self.r = self.x
107 self.mdot = self.y
108 self.dmdotdr = self.dydx
109