-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made solution data memory layout consistent between cpu and gpu for M…
…ultimodeNLSE. Moved initial pulse generation code to separate file. Updated unit test.
- Loading branch information
1 parent
c539427
commit a882015
Showing
9 changed files
with
156 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// nlse++ | ||
// C++ library for solving the nonlinear Schrödinger equation | ||
// Licensed under the MIT License (http://opensource.org/licenses/MIT) | ||
// Copyright (c) 2023, Savithru Jayasinghe | ||
|
||
#define _USE_MATH_DEFINES //For MSVC | ||
#include <cmath> | ||
|
||
#include <autodiffeq/linearalgebra/Array1D.hpp> | ||
|
||
namespace autodiffeq | ||
{ | ||
|
||
template<typename T, typename Ts> | ||
inline void ComputeGaussianPulse(const Array1D<T>& Et, const Array1D<T>& t_FWHM, const Array1D<T>& t_center, | ||
const Array1D<double>& time_vec, Array1D<Ts>& sol) | ||
{ | ||
const int num_modes = (int) Et.size(); | ||
const int num_time_points = (int) time_vec.size(); | ||
assert(num_modes == (int) t_FWHM.size()); | ||
assert(num_modes == (int) t_center.size()); | ||
sol.resize(num_modes * num_time_points); | ||
|
||
for (int mode = 0; mode < num_modes; ++mode) | ||
{ | ||
const double A = std::sqrt(1665.0*Et(mode) / ((double)num_modes * t_FWHM(mode) * std::sqrt(M_PI))); | ||
const double k = -1.665*1.665/(2.0*t_FWHM(mode)*t_FWHM(mode)); | ||
const double& tc = t_center(mode); | ||
|
||
#pragma omp parallel for | ||
for (int j = 0; j < num_time_points; ++j) | ||
sol(j*num_modes + mode) = A * std::exp(k*(time_vec(j)-tc)*(time_vec(j)-tc)); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.