# include # include using namespace std; # include "sine_gordon_exact.hpp" //****************************************************************************80 void sine_gordon_exact ( double a, double x, double y, double *u, double *uxy ) //****************************************************************************80 // // Purpose: // // sine_gordon_exact() evaluates an exact solution of the Sine-Gordeon PDE. // // Discussion: // // uxy = sin ( u ) // // This is a one-soliton solution. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 02 May 2024 // // Author: // // John Burkardt // // Reference: // // Daniel Arrigo, // Analytical Techniques for Solving Nonlinear Partial Differential Equations, // Morgan and Clayfoot, 2019, // ISBN: 978 168 173 5351. // // Input: // // double A: a parameter. // // double X, Y: the X and Y coordinates of a point. // // Output: // // double *U, *UXY: the values of the solution, and its first // mixed derivative at (X,Y). // { *u = 4.0 * atan ( exp ( a * x + y / a ) ); *uxy = 4.0 * ( exp ( a * x + y / a ) - exp ( 3 * a * x + 3 * y / a ) ) / pow ( 1.0 + exp ( 2 * a * x + 2 * y / a ), 2 ); return; } //****************************************************************************80 double sine_gordon_residual ( double u, double uxy ) //****************************************************************************80 // // Purpose: // // sine_gordon_residual() evaluates the residual for the Sine-Gordeon PDE. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 02 May 2024 // // Author: // // John Burkardt // // Reference: // // Daniel Arrigo, // Analytical Techniques for Solving Nonlinear Partial Differential Equations, // Morgan and Clayfoot, 2019, // ISBN: 978 168 173 5351. // // Input: // // double U, UXY: the values of the solution, and its // first mixed derivative. // // Output: // // double R, the residual. // { double r; r = uxy - sin ( u ); return r; }