Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance concern in GammaHandler::photoIonization #79

Closed
kreczko opened this issue Nov 20, 2020 · 0 comments
Closed

Performance concern in GammaHandler::photoIonization #79

kreczko opened this issue Nov 20, 2020 · 0 comments

Comments

@kreczko
Copy link
Contributor

kreczko commented Nov 20, 2020

Dear @Gratt55,

In the function GammaHandler::photoIonization is the first dimension of sourceInfo expected to be large (e.g. > 10)?

If yes, it might be worth changing

double GammaHandler::photoIonization(vector<vector<double>> sourceInfo, vector<double> xyTry) {
	//implement simple delta function to the spectrum
	double fValue = 0.0;
	for(int i = 0; i < sourceInfo.size(); i++) {
		double initialEnergy = sourceInfo[i][0];
		double br = sourceInfo[i][1];
		double pe = sourceInfo[i][2];
		double co = sourceInfo[i][3];
		double pp = sourceInfo[i][4];
		if(abs(xyTry[0]-initialEnergy) < brThresh) {
			fValue = yMax*br*(pe/(pe+co+pp));
		}
	}
	return fValue;
}

to

double GammaHandler::photoIonization(const vector<vector<double>>& sourceInfo, 
     const vector<double>& xyTry) {
	//implement simple delta function to the spectrum
	double value {0.0};
        std::size_t index {0};
	for(int i = 0; i < sourceInfo.size(); i++) {
	  double initialEnergy {sourceInfo[i][0]};
          if(abs(xyTry[0] - initialEnergy) < brThresh) {
            index = i;
	  }
	}
        double br = sourceInfo[index][1];
	double pe = sourceInfo[index][2];
	double co = sourceInfo[index][3];
	double pp = sourceInfo[index][4];
        value = yMax * br * ( pe / (pe + co + pp) );
	return value;
}

(also changed fValuevalue as f<Name> is usually the notation for class members, not local variables).

kreczko added a commit to kreczko/nest that referenced this issue Nov 20, 2020
mszydagis pushed a commit that referenced this issue Nov 20, 2020
* fixed issue #79

* use PI constant instead of self-defined value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants