Skip to content

Commit bdbf0b7

Browse files
authored
Merge pull request #71 from ldvries/development
Adding features for Manakov equation
2 parents 681191c + b47e265 commit bdbf0b7

File tree

153 files changed

+10107
-657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+10107
-657
lines changed

.gitignore

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
!Doxyfile
77

88
# Unignore subdirectories
9-
#!/examples/
9+
!/examples/
1010
!/include/
1111
!/include/private/
1212
!/include/3rd_party/eiscor/
@@ -16,7 +16,24 @@
1616
!/src/private/
1717
!/src/3rd_party/eiscor/
1818
!/src/3rd_party/kiss_fft/
19-
#!/test/
19+
!/test/
20+
!/test/fnft__akns_fscatter/
21+
!/test/fnft__fft_wrapper/
22+
!/test/fnft__kdv_finvscatter/
23+
!/test/fnft__kdv_scatter/
24+
!/test/fnft_kdvv/
25+
!/test/fnft__manakov_fscatter/
26+
!/test/fnft__manakov_scatter/
27+
!/test/fnft_manakovv/
28+
!/test/fnft__misc/
29+
!/test/fnft__nse_finvscatter/
30+
!/test/fnft_nsep/
31+
!/test/fnft__nse_scatter/
32+
!/test/fnft_nsev/
33+
!/test/fnft_nsev_inverse/
34+
!/test/fnft__poly/
35+
!/test/fnft_version_test/
36+
!/test/fnft_version_test.c/
2037

2138
# Ignore MacOS hidden files in subdirectories
2239
/**/*.DS_Store
@@ -36,6 +53,7 @@
3653
!/**/*.h
3754
!/**/*.h.in
3855
!/**/*.m
56+
!/**/*.inc
3957

4058
# Explicitly reignore fnft_config.h, which is generated by cmake
4159
/include/fnft_config.h

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,4 @@ if (WITH_MATLAB)
223223
# -DMEX_DOUBLE_HANDLE avoids the new complex interleaved API
224224
endforeach()
225225
endif()
226-
endif()
226+
endif()

Doxyfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ OUTPUT_LANGUAGE = English
9999
# Possible values are: None, LTR, RTL and Context.
100100
# The default value is: None.
101101

102-
OUTPUT_TEXT_DIRECTION = None
102+
#OUTPUT_TEXT_DIRECTION = None # OBSOLETE
103103

104104
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
105105
# descriptions after the members that are listed in the file and class
@@ -1858,7 +1858,7 @@ LATEX_HIDE_INDICES = NO
18581858
# The default value is: NO.
18591859
# This tag requires that the tag GENERATE_LATEX is set to YES.
18601860

1861-
LATEX_SOURCE_CODE = NO
1861+
# LATEX_SOURCE_CODE = NO # OBSOLETE
18621862

18631863
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
18641864
# bibliography, e.g. plainnat, or ieeetr. See
@@ -1948,7 +1948,7 @@ RTF_EXTENSIONS_FILE =
19481948
# The default value is: NO.
19491949
# This tag requires that the tag GENERATE_RTF is set to YES.
19501950

1951-
RTF_SOURCE_CODE = NO
1951+
# RTF_SOURCE_CODE = NO # OBSOLETE
19521952

19531953
#---------------------------------------------------------------------------
19541954
# Configuration options related to the man page output
@@ -2053,7 +2053,7 @@ DOCBOOK_OUTPUT = docbook
20532053
# The default value is: NO.
20542054
# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
20552055

2056-
DOCBOOK_PROGRAMLISTING = NO
2056+
#DOCBOOK_PROGRAMLISTING = NO # OBSOLETE
20572057

20582058
#---------------------------------------------------------------------------
20592059
# Configuration options for the AutoGen Definitions output

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,26 @@ FNFT is a software library for the numerical computation of (inverse) nonlinear
1111
* Nonlinear Schroedinger equation
1212

1313
* Vanishing boundary conditions
14-
* Reflection coefficient and/or scattering coefficients (a and b)
15-
* Bound states (eigenvalues)
16-
* Norming constants and/or residues
14+
* Reflection coefficient and/or scattering coefficients (a and b)
15+
* Bound states (eigenvalues)
16+
* Norming constants and/or residues
1717

1818
* (Quasi-)Periodic boundary conditions
19-
* Main spectrum
20-
* Auxiliary spectrum
19+
* Main spectrum
20+
* Auxiliary spectrum
2121

2222
* Korteweg-de Vries equation
23-
* Vanishing boundary conditions (reflection coefficient only)
23+
24+
* Vanishing boundary conditions
25+
* Reflection coefficient and/or scattering coefficients (a and b)
26+
* Bound states (eigenvalues)
27+
* Norming constants and/or residues
28+
29+
* Manakov equation
30+
31+
* Vanishing boundary conditions
32+
* Reflection coefficient and/or scattering coefficients (a, b1 and b2)
33+
* Bound states (eigenvalues)
2434

2535
### Inverse Transforms
2636

@@ -71,6 +81,7 @@ Please use the [issue tracker](https://github.com/FastNFT/FNFT/issues) to report
7181
* Shrinivas Chimmalgi, TU Delft
7282
* Peter J. Prins, TU Delft
7383
* Marius Brehler, TU Dortmund
84+
* Lianne de Vries, student TU Delft
7485

7586
## License
7687

examples/fnft_manakovv_example.c

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* This file is part of FNFT.
3+
*
4+
* FNFT is free software; you can redistribute it and/or
5+
* modify it under the terms of the version 2 of the GNU General
6+
* Public License as published by the Free Software Foundation.
7+
*
8+
* FNFT is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*
16+
* Contributors:
17+
* Lianne de Vries (TU Delft student) 2021.
18+
*/
19+
20+
#define FNFT_ENABLE_SHORT_NAMES
21+
22+
#include <stdio.h> // for printf
23+
#include "fnft_manakovv.h"
24+
#include "fnft_manakov_discretization_t.h"
25+
#include "fnft__misc.h"
26+
27+
int main()
28+
{
29+
/** Step 1: Set up the signal **/
30+
31+
// Number of time-domain samples. Increase to improve precision of results.
32+
FNFT_UINT D = 1024;
33+
34+
// Contains the samples of q(t)
35+
FNFT_COMPLEX q1[D], q2[D];
36+
37+
// Location of the 1st and last time-domain sample
38+
FNFT_REAL T[2] = { -2.0, 2.0 };
39+
40+
// Define a simple rectangular signal
41+
// TODO: use rectangular signal
42+
for (UINT i=0; i<D; i++){
43+
q1[i] = 2;
44+
q2[i] = 0.65;
45+
}
46+
47+
// The types FNFT_UINT, FNFT_INT, FNFT_REAL and FNFT_COMPLEX are defined
48+
// in the header fnft_numtypes.h
49+
50+
51+
/** Step 2: Prepare calling fnft_manakovv **/
52+
53+
// Location of the 1st and last sample of the continuous spectrum
54+
FNFT_REAL XI[2] = {-1.75, 2.0 };
55+
56+
// Number of samples of the continuous spectrum
57+
FNFT_UINT M = 8;
58+
59+
// Buffer for result: Samples of the continuous spectrum
60+
FNFT_COMPLEX contspec[3*M];
61+
62+
63+
// Maximum number of bound states we expect = size of the two arrays below
64+
FNFT_UINT K = D;
65+
66+
// Buffer for result: Bound states
67+
FNFT_COMPLEX bound_states[K];
68+
69+
// Buffer for result: Norming constants
70+
FNFT_COMPLEX normconsts[K];
71+
72+
// Focusing nonlinear Schroedinger equation
73+
int kappa = +1;
74+
75+
// Default options
76+
fnft_manakovv_opts_t opts = fnft_manakovv_default_opts();
77+
opts.discretization = manakov_discretization_2SPLIT3A;
78+
79+
// Uncomment the next line to compute residues instead of norming constants
80+
//opts.discspec_type = fnft_nsev_dstype_RESIDUES;
81+
82+
// See the header file fnft_nsev.h for other options
83+
84+
/** Step 3: Call fnft_nsev and check for errors **/
85+
86+
int ret_code = fnft_manakovv(D, q1, q2, T, M, contspec, XI, &K, bound_states,
87+
normconsts, kappa, &opts);
88+
if (ret_code != FNFT_SUCCESS) {
89+
printf("An error occured!\n");
90+
return EXIT_FAILURE;
91+
}
92+
93+
/** Step 4: Print the results **/
94+
95+
printf("Number of samples:\n D = %u\n", (unsigned int)D);
96+
97+
FNFT_REAL eps_xi = (XI[1] - XI[0]) / (M - 1);
98+
printf("Continuous spectrum (first entry):\n");
99+
for (FNFT_UINT i=0; i<M; i++) {
100+
FNFT_REAL xi = XI[0] + i*eps_xi;
101+
printf(" continuous_spectrum(xi=%f) \t= %g + %gI\n",
102+
(double)xi,
103+
(double)FNFT_CREAL(contspec[i]),
104+
(double)FNFT_CIMAG(contspec[i])
105+
);
106+
}
107+
108+
printf("Continuous spectrum (second entry):\n");
109+
for (FNFT_UINT i=M; i<2*M; i++) {
110+
FNFT_REAL xi = XI[0] + (i-8)*eps_xi;
111+
printf(" continuous_spectrum(xi=%f) \t= %g + %gI\n",
112+
(double)xi,
113+
(double)FNFT_CREAL(contspec[i]),
114+
(double)FNFT_CIMAG(contspec[i])
115+
);
116+
}
117+
118+
/* printf("Discrete spectrum:\n");
119+
for (FNFT_UINT i=0; i<K; i++) {
120+
printf(" bound state at %g + %gI with norming constant %g + %gI\n",
121+
(double)FNFT_CREAL(bound_states[i]),
122+
(double)FNFT_CIMAG(bound_states[i]),
123+
(double)FNFT_CREAL(normconsts[i]),
124+
(double)FNFT_CIMAG(normconsts[i])
125+
);
126+
}*/
127+
128+
return EXIT_SUCCESS;
129+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
% This file is part of FNFT.
2+
%
3+
% FNFT is free software; you can redistribute it and/or
4+
% modify it under the terms of the version 2 of the GNU General
5+
% Public License as published by the Free Software Foundation.
6+
%
7+
% FNFT is distributed in the hope that it will be useful,
8+
% but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
% GNU General Public License for more details.
11+
%
12+
% You should have received a copy of the GNU General Public License
13+
% along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
%
15+
% Contributors:
16+
% Sander Wahls (TU Delft) 2017-2018, 2021.
17+
% Lianne de Vries (TU Delft student) 2021.
18+
19+
% This examples demonstrates how the nonlinear Fourier transform with
20+
% respect to the Manakov equation with vanishing boundary
21+
% conditions can be computed using mex_fnft_manakovv. The signal is a sech
22+
% pulse as discussed in
23+
% http://resolver.tudelft.nl/uuid:0276e693-3408-4472-9749-b754c2114183
24+
25+
26+
clear all;
27+
close all;
28+
29+
%%% Setup parameters %%%
30+
31+
T = [-7, 7]; % location of the 1st and last sample in the time domain
32+
D = 512; % number of samples
33+
XI = [-7/4, 8/4]; % location of the 1st and last sample in the xi-domain
34+
kappa = +1; % focusing nonlinear Schroedinger equation
35+
36+
%%% Setup the signal %%%
37+
38+
eps_t = (T(2) - T(1)) / (D - 1); % time domain step size
39+
t = T(1):eps_t:T(2);
40+
q1 = 0.8*sech(t); % signal samples
41+
q2 = 5.2*sech(t);
42+
43+
%%% Compute the nonlinear Fourier transform %%%
44+
45+
[contspec, bound_states] = mex_fnft_manakovv(complex(q1), complex(q2), ...
46+
T, XI, kappa);
47+
% mex_fnft_manakovv has many options => run "help mex_fnft_manakovv" to
48+
% learn more
49+
50+
%%% Plot the results %%%
51+
52+
ep_xi = (XI(2) - XI(1)) / (D - 1);
53+
xi = XI(1):ep_xi:XI(2); % grid in the nonlinear frequency domain
54+
55+
figure;
56+
plot(t, real(q1), t, imag(q1));
57+
title('Time-domain');
58+
xlabel('t');
59+
ylabel('q1(t)');
60+
legend('Real part', 'Imaginary part');
61+
62+
figure;
63+
plot(t, real(q2), t, imag(q2));
64+
title('Time-domain');
65+
xlabel('t');
66+
ylabel('q2(t)');
67+
legend('Real part', 'Imaginary part');
68+
69+
% Note: plotting the results for the default case where
70+
% contspec = [rho1; rho2]. If different inputs are chosen for cstype or M
71+
% plots should be adjusted
72+
figure;
73+
plot(xi, real(contspec(1:length(contspec)/2)), xi, ...
74+
imag(contspec(1:length(contspec)/2)));
75+
title('Continuous spectrum, first element');
76+
xlabel('\xi');
77+
ylabel('r(\xi)');
78+
legend('Real part', 'Imaginary part');
79+
80+
figure;
81+
plot(xi, real(contspec(length(contspec)/2+1:length(contspec))), xi, ...
82+
imag(contspec(length(contspec)/2+1:length(contspec))));
83+
title('Continuous spectrum, second element');
84+
xlabel('\xi');
85+
ylabel('r(\xi)');
86+
legend('Real part', 'Imaginary part');

0 commit comments

Comments
 (0)