iniSCMHalo = dict(ini.items("SelfConsistentModel halo")) iniSCMBulge = dict(ini.items("SelfConsistentModel bulge")) iniSCMDisk = dict(ini.items("SelfConsistentModel disk")) iniSCM = dict(ini.items("SelfConsistentModel")) # initialize the SelfConsistentModel object (only the potential expansion parameters) model = agama.SelfConsistentModel(**iniSCM) # create initial density profiles of all components densityDisk = agama.Density(**iniPotenDisk) densityBulge = agama.Density(**iniPotenBulge) densityHalo = agama.Density(**iniPotenHalo) potentialBH = agama.Potential(**iniPotenBH) # add components to SCM - at first, all of them are static density profiles model.components.append(agama.Component(density=densityDisk, disklike=True)) model.components.append(agama.Component(density=densityBulge, disklike=False)) model.components.append(agama.Component(density=densityHalo, disklike=False)) model.components.append(agama.Component(potential=potentialBH)) # compute the initial potential model.iterate() printoutInfo(model,'init') # construct the DF of the disk component, using the initial (non-spherical) potential dfDisk = agama.DistributionFunction(potential=model.potential, **iniDFDisk) # initialize the DFs of spheroidal components using the Eddington inversion formula # for their respective density profiles in the initial potential dfBulge = agama.DistributionFunction(type='QuasiSpherical', potential=model.potential, density=densityBulge) dfHalo = agama.DistributionFunction(type='QuasiSpherical', potential=model.potential, density=densityHalo)
# define external unit system describing the data (including the parameters in INI file) agama.setUnits(length=1, velocity=1, mass=1) # in Kpc, km/s, Msun # initialize the SelfConsistentModel object (only the potential expansion parameters) model = agama.SelfConsistentModel(**iniSCM) # create initial ('guessed') density profiles of all components densityBulge = agama.Density(**iniPotenBulge) densityDarkHalo = agama.Density(**iniPotenDarkHalo) densityThinDisk = agama.Density(**iniPotenThinDisk) densityThickDisk = agama.Density(**iniPotenThickDisk) densityGasDisk = agama.Density(**iniPotenGasDisk) densityStellarDisk = agama.Density(densityThinDisk, densityThickDisk) # composite # add components to SCM - at first, all of them are static density profiles model.components.append(agama.Component(density=densityStellarDisk, disklike=True)) model.components.append(agama.Component(density=densityBulge, disklike=False)) model.components.append(agama.Component(density=densityDarkHalo, disklike=False)) model.components.append(agama.Component(density=densityGasDisk, disklike=True)) # compute the initial potential model.iterate() printoutInfo(model, "init") print("\033[1;33m**** STARTING MODELLING ****\033[0m\nInitial masses of density components: " \ "Mdisk=%g Msun, Mbulge=%g Msun, Mhalo=%g Msun, Mgas=%g Msun" % \ (densityStellarDisk.totalMass(), densityBulge.totalMass(), \ densityDarkHalo.totalMass(), densityGasDisk.totalMass())) # create the dark halo DF dfHalo = agama.DistributionFunction(potential=model.potential, **iniDFDarkHalo)
determined by its distribution function in terms of actions """ import agama, numpy, matplotlib.pyplot as plt # the distribution function defining the model df = agama.DistributionFunction(type="DoublePowerLaw", J0=1, slopeIn=0, slopeOut=6, norm=30) mass = df.totalMass() scaleradius = 2. # educated guess # initial guess for the density profile dens = agama.Density(type='Plummer', mass=mass, scaleRadius=scaleradius) print "DF mass=", mass, ' Density mass=', dens.totalMass() # should be identical # define the self-consistent model consisting of a single component params = dict(rminSph=0.01, rmaxSph=100., sizeRadialSph=25, lmaxAngularSph=0) comp = agama.Component(df=df, density=dens, disklike=False, **params) scm = agama.SelfConsistentModel(**params) scm.components=[comp] # prepare visualization r=numpy.logspace(-2.,2.) xyz=numpy.vstack((r,r*0,r*0)).T plt.plot(r, dens.density(xyz), label='Init density') # perform several iterations of self-consistent modelling procedure for i in range(5): scm.iterate() print 'Iteration', i, ' Phi(0)=', scm.potential.potential(0,0,0), ' Mass=', scm.potential.totalMass() plt.plot(r, scm.potential.density(xyz), label='Iteration #'+str(i)) # save the final density/potential profile
iniDFDisk = dict(ini.items("DF disk")) iniSCMHalo = dict(ini.items("SelfConsistentModel halo")) iniSCMBulge = dict(ini.items("SelfConsistentModel bulge")) iniSCMDisk = dict(ini.items("SelfConsistentModel disk")) iniSCM = dict(ini.items("SelfConsistentModel")) # initialize the SelfConsistentModel object (only the potential expansion parameters) model = agama.SelfConsistentModel(**iniSCM) # create initial ('guessed') density profiles of all components densityBulge = agama.Density(**iniPotenBulge) densityHalo = agama.Density(**iniPotenHalo) densityDisk = agama.Density(**iniPotenDisk) # add components to SCM - at first, all of them are static density profiles model.components.append(agama.Component(dens=densityHalo, disklike=False)) model.components.append(agama.Component(dens=densityBulge, disklike=False)) model.components.append(agama.Component(dens=densityDisk, disklike=True)) # compute the initial potential model.iterate() writeRotationCurve("rotcurve_init", model.pot) # initialize the DFs of spheroidal components using the Eddington inversion formula # for their respective density profiles in the spherically-symmetric initial guess for the potential pot_sph = agama.Potential(type='Multipole', density=model.pot, lmax=0, gridsizer=100, rmin=1e-3, rmax=1e3)
cutoffStrength=0.7194) d2 = agama.Density(type='Spheroid', DensityNorm=0.9 * 169.975, gamma=0, beta=0, axisRatioZ=0.37, outerCutoffRadius=0.0246, cutoffStrength=0.7933) density_NSD_init = agama.Density(d1, d2) # add both NSC and NSD components as static density profiles for the moment: # assign both of them to a single CylSpline potential solver by setting disklike=True # and thus avoid creating an additional Multipole potential, which is typically used # for spheroidal components - this reduces computational cost by roughly a half model.components.append( agama.Component(density=density_NSC_init, disklike=True)) model.components.append( agama.Component(density=density_NSD_init, disklike=True)) # compute the initial guess for the potential model.iterate() plotVcirc(model, 0) # introduce DF for the NSD component mass = 0.097 Rdisk = 0.075 Hdisk = 0.025 sigmar0 = 75.0 Rsigmar = 1.0 sigmamin = 2.0 Jmin = 10.0
# initialize the SelfConsistentModel object (only the potential expansion parameters) model = agama.SelfConsistentModel(**iniSCM) # create initial ('guessed') density profiles of all components densityBulge = agama.Density(**iniPotenBulge) densityDarkHalo = agama.Density(**iniPotenDarkHalo) densityThinDisc = agama.Density(**iniPotenThinDisc) densityThickDisc = agama.Density(**iniPotenThickDisc) densityGasDisc = agama.Density(**iniPotenGasDisc) densityStellarDisc = agama.Density(densityThinDisc, densityThickDisc) # composite # add components to SCM - at first, all of them are static density profiles model.components.append( agama.Component(dens=densityDarkHalo, disklike=False)) model.components.append( agama.Component(dens=densityStellarDisc, disklike=True)) model.components.append(agama.Component(dens=densityBulge, disklike=False)) model.components.append(agama.Component(dens=densityGasDisc, disklike=True)) # compute the initial potential model.iterate() writeRotationCurve("rotcurve_init", model.pot) print "**** STARTING ONE-COMPONENT MODELLING ****\nMasses are: " \ "Mbulge=%g Msun,"% densityBulge.totalMass(), \ "Mgas=%g Msun," % densityGasDisc.totalMass(), \ "Mdisc=%g Msun," % densityStellarDisc.totalMass(), \ "Mhalo=%g Msun" % densityDarkHalo.totalMass()