Ejemplo n.º 1
0
    def iterate_lte_ne_eq_pops(self, atmos: Atmosphere):
        atmos.nondimensionalise()
        maxIter = 500
        prevNe = np.copy(atmos.ne)
        ne = np.copy(atmos.ne)
        for it in range(maxIter):
            atomicPops = []
            prevNe[:] = ne
            ne.fill(0.0)
            for a in sorted(self.atoms, key=atomic_weight_sort):
                nTotal = self.atomicTable[a.name].abundance * atmos.nHTot
                nStar = lte_pops(a, atmos, nTotal, debye=True)
                atomicPops.append(AtomicState(a, nStar, nTotal))
                stages = np.array([l.stage for l in a.levels])
                # print(stages)
                ne += np.sum(nStar * stages[:, None], axis=0)
                # print(ne)
            atmos.ne[:] = ne

            relDiff = np.nanmax(np.abs(1.0 - prevNe / ne))
            print(relDiff)
            maxRelDiff = np.nanmax(relDiff)
            if maxRelDiff < 1e-3:
                print("Iterate LTE: %d iterations" % it)
                break
        else:
            print("LTE ne failed to converge")

        atmos.dimensionalise()
        table = AtomicStateTable(atmos, self.atomicTable, atomicPops)
        return table
Ejemplo n.º 2
0
 def update_nTotal(self, atmos : Atmosphere):
     dim = False
     if atmos.dimensioned:
         dim = True
         atmos.nondimensionalise()
     self.nTotal[:] = self.model.atomicTable[self.name].abundance * atmos.nHTot
     if dim:
         atmos.dimensionalise()