Пример #1
0
void Events::adsorbIslands(int nIslands, int islandSize)
{
	for (int i = 0; i < nIslands; i++) {
		int position = static_cast<int> (floor(_random() * c::A));
		for (int j = 0; j < islandSize; j++) {
			adsorption(neigh::neigh(n, position), atomType::silicon);
		}
	}
}
Пример #2
0
void Events::execute()
{
	evolve();

newChoose:;

	double chooseEvent = _random() * rates.total;

	if (chooseEvent < rates.totalAds) {
		int index = static_cast<int> (floor(chooseEvent / rates.ads));

		adsorption(index, atomType::metal);
	}
	else if (chooseEvent < rates.totalAds + rates.totalDes) {
		chooseEvent -= rates.totalAds;
		double cumulateRates = 0;
		unsigned ei = 0, ej = 0;
      while (cumulateRates + rates.sumsofDes[ei] < chooseEvent) {
         if (ei >= c::nDesTypes) {
            goto newChoose;
         }
         cumulateRates += rates.sumsofDes[ei++];
      }
      ej = static_cast<int> (floor((chooseEvent - cumulateRates) / rates.des[ei]));
      if (ej >= eventLists._desEvents[ei].size()) {
         goto newChoose;
      }/*

		if (ei % c::nNeighCount == 0)
			_nFreeDes++;

      _nDesorbNeigh[ei % c::nNeighCount]++;*/

		desorption(eventLists._desEvents[ei][ej]);
	}
	else {
		chooseEvent -= rates.totalAds + rates.totalDes;
		double cumulateRates = 0;
		unsigned ei = 0, ej = 0;
      while (cumulateRates + rates.sumsofDiff[ei] < chooseEvent) {
         if (ei >= c::nDiffTypes) {
            goto newChoose;
         }
         cumulateRates += rates.sumsofDiff[ei++];
      }
		ej = static_cast<int> (floor((chooseEvent - cumulateRates) / rates.diff[ei]));
      if (ej >= eventLists._diffEvents[ei].size()) {
         goto newChoose;
      }
		checkDiff(ei, eventLists._diffEvents[ei][ej]);
		diffusion(eventLists._diffEvents[ei][ej]);
   }
   _nEvents++;
}
Пример #3
0
    V
    PolymerPropsAd::effectiveRelPerm(const V& c,
                                     const V& cmax_cells,
                                     const V& krw) const
    {
        const int nc = c.size();

        V one  = V::Ones(nc);
        V ads = adsorption(c, cmax_cells);
        double max_ads = polymer_props_.cMaxAds();
        double res_factor = polymer_props_.resFactor();
        double factor = (res_factor -1.) / max_ads;
        V rk = one + factor * ads;

        return krw / rk;
    }
Пример #4
0
    ADB
    PolymerPropsAd::effectiveRelPerm(const ADB& c,
                                     const ADB& cmax_cells,
                                     const ADB& krw) const
    {
        const int nc = c.value().size();
        V one = V::Ones(nc);
        ADB ads = adsorption(c, cmax_cells);
        V krw_eff = effectiveRelPerm(c.value(), cmax_cells.value(), krw.value());

        double max_ads = polymer_props_.cMaxAds();
        double res_factor = polymer_props_.resFactor();
        double factor = (res_factor - 1.) / max_ads;
        ADB rk = one + ads * factor;

        return krw / rk;
    }
Пример #5
0
simulationReturn Events::growthSimulation()
{
	/*std::cout << std::endl;
	for (int i = 0; i < 4; i++) {
		std::cout << evolution._rates.getRate(0, i, 0);
	}
	for (int i = 0; i < 4; i++) {
		std::cout << evolution._rates.getRate(i, 0, 0);
	}
	std::cin.ignore();*/

	int position = c::A / 2 + c::w / 3;
	//for (int n = 0; n < 6; n++) {
	//	adsorption(neigh::neigh(n,position), atomType::silicon);
	//}
	adsorption(position, atomType::silicon);

	int nShows = 10;
	double currTarget = _targetCoverage / 10;

   while (_getCoverage() < _targetCoverage) {
      if (_nEvents % 1000000 == 0) {
			std::cout << _nEvents << "\t" << _getCoverage() << std::endl;
			if (crossCheck(false) != 0) {
				crossCheck();
				std::cin.ignore();
			}
      }
		if (_getCoverage() > currTarget) {
			results.addGridState(grid._lattice);
			results.addRow(getResultVector());
			currTarget += _targetCoverage / 10;
		}
      execute();
	}
	crossCheck();
   results.addGridState(grid._lattice);
   results.addRow(getResultVector());

	/*double relaxTime = 50.0;
	double targetTime = evolution._masterTime + relaxTime;

	evolution._rates.ads = 0.0;
	evolution._rates.totalAds = 0.0;

	while (evolution._masterTime < targetTime) {
		if (_nEvents % 1000000 == 0) {
			std::cout << _nEvents << "\t" << _getCoverage() << std::endl;
			if (crossCheck(false) != 0) {
				crossCheck();
				std::cin.ignore();
			}
		}
		execute();
	}
	crossCheck();
	results.addGridState(grid._lattice);
	results.addRow(getResultVector());*/

   return simulationReturn::allright;
}