⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nonlinearwaveequations-source.nb

📁 Simulate Nonlinear Wave Equations in Mathematica
💻 NB
📖 第 1 页 / 共 2 页
字号:
(* Content-type: application/mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 6.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       145,          7]
NotebookDataLength[     18067,        480]
NotebookOptionsPosition[     16983,        439]
NotebookOutlinePosition[     17596,        463]
CellTagsIndexPosition[     17553,        460]
WindowFrame->Normal
ContainsDynamic->True *)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["Nonlinear Wave Equations", "Section",
 CellFrameColor->RGBColor[
  0.6449835965514611, 0.758632791638056, 0.2516823071641108],
 FontColor->RGBColor[
  0.6449835965514611, 0.758632791638056, 0.2516823071641108]],

Cell[BoxData[
 RowBox[{"Manipulate", "[", 
  RowBox[{
   RowBox[{
    RowBox[{"If", "[", 
     RowBox[{"ct", ",", "DensityPlot", ",", "Plot3D"}], "]"}], "[", 
    RowBox[{
     RowBox[{"Evaluate", "[", 
      RowBox[{
       RowBox[{"u", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{"ct", ",", 
           RowBox[{"x0", "-", "t"}], ",", "t"}], "]"}], ",", "x"}], "]"}], "/.",
        
       RowBox[{"Quiet", "[", 
        RowBox[{"NDSolve", "[", 
         RowBox[{
          RowBox[{"Evaluate", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{
              RowBox[{"D", "[", 
               RowBox[{
                RowBox[{"u", "[", 
                 RowBox[{"t", ",", "x"}], "]"}], ",", "t", ",", "t"}], "]"}], 
              "\[Equal]", 
              RowBox[{
               RowBox[{"D", "[", 
                RowBox[{
                 RowBox[{"u", "[", 
                  RowBox[{"t", ",", "x"}], "]"}], ",", "x", ",", "x"}], "]"}],
                "+", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{"0", ",", 
                  RowBox[{"Sin", "[", 
                   RowBox[{"u", "[", 
                    RowBox[{"t", ",", "x"}], "]"}], "]"}], ",", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", 
                    RowBox[{
                    RowBox[{"u", "[", 
                    RowBox[{"t", ",", "x"}], "]"}], "^", "2"}]}], ")"}], "*", 
                   
                   RowBox[{"(", 
                    RowBox[{"1", "+", 
                    RowBox[{"u", "[", 
                    RowBox[{"t", ",", "x"}], "]"}]}], ")"}]}]}], "}"}], "[", 
                RowBox[{"[", "f", "]"}], "]"}]}]}], ",", 
             RowBox[{
              RowBox[{"u", "[", 
               RowBox[{"0", ",", "x"}], "]"}], "\[Equal]", 
              RowBox[{
               RowBox[{"E", "^", 
                RowBox[{"(", 
                 RowBox[{"-", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"x", "-", "a"}], ")"}], "^", "2"}]}], ")"}]}], 
               "+", 
               RowBox[{"E", "^", 
                RowBox[{"(", 
                 RowBox[{"-", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"x", "+", "a"}], ")"}], "^", "2"}]}], ")"}]}]}]}],
              ",", 
             RowBox[{
              RowBox[{
               RowBox[{"D", "[", 
                RowBox[{
                 RowBox[{"u", "[", 
                  RowBox[{"t", ",", "x"}], "]"}], ",", "t"}], "]"}], 
               "\[Equal]", "0"}], "/.", 
              RowBox[{"t", "\[Rule]", "0"}]}], ",", 
             RowBox[{
              RowBox[{"u", "[", 
               RowBox[{"t", ",", 
                RowBox[{"-", "x0"}]}], "]"}], "\[Equal]", 
              RowBox[{"u", "[", 
               RowBox[{"t", ",", "x0"}], "]"}]}]}], "}"}], "]"}], ",", "u", 
          ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "x0"}], "}"}], ",", 
          RowBox[{"{", 
           RowBox[{"x", ",", 
            RowBox[{"-", "x0"}], ",", "x0"}], "}"}], ",", 
          RowBox[{"Method", "\[Rule]", 
           RowBox[{"{", 
            RowBox[{"\"\<MethodOfLines\>\"", ",", 
             RowBox[{"\"\<SpatialDiscretization\>\"", "\[Rule]", 
              RowBox[{"{", 
               RowBox[{"\"\<TensorProductGrid\>\"", ",", 
                RowBox[{
                "\"\<DifferenceOrder\>\"", "\[Rule]", 
                 "\"\<Pseudospectral\>\""}], ",", 
                RowBox[{"\"\<MinStepSize\>\"", "\[Rule]", "0.2"}]}], 
               "}"}]}]}], "}"}]}]}], "]"}], "]"}]}], "]"}], ",", 
     RowBox[{"{", 
      RowBox[{"x", ",", 
       RowBox[{"-", "x0"}], ",", "x0"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"t", ",", "0", ",", "x0"}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"Mesh", "\[Rule]", "mesh"}], ",", 
     RowBox[{"MeshFunctions", "\[Rule]", 
      RowBox[{"{", 
       RowBox[{"#3", "&"}], "}"}]}], ",", 
     RowBox[{"ColorFunction", "\[Rule]", "\"\<Rainbow\>\""}], ",", 
     RowBox[{"PlotPoints", "\[Rule]", "30"}], ",", 
     RowBox[{"MaxRecursion", "\[Rule]", 
      RowBox[{"ControlActive", "[", 
       RowBox[{"1", ",", "2"}], "]"}]}], ",", 
     RowBox[{"ImageSize", "\[Rule]", 
      RowBox[{"{", 
       RowBox[{"475", ",", "325"}], "}"}]}], ",", 
     RowBox[{"ImagePadding", "\[Rule]", "15"}]}], "]"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"f", ",", "2", ",", "\"\<equation\>\""}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"1", "\[Rule]", "\"\<wave\>\""}], ",", 
       RowBox[{"2", "\[Rule]", "\"\<sine-Gordon\>\""}], ",", 
       RowBox[{"3", "\[Rule]", "\"\<Wolfram\>\""}]}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"a", ",", "0", ",", "\"\<initial peak separation\>\""}], "}"}], 
     ",", "0", ",", "10"}], "}"}], ",", "\[IndentingNewLine]", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"x0", ",", "10", ",", "\"\<solution range\>\""}], "}"}], ",", 
     "5", ",", "20"}], "}"}], ",", "\[IndentingNewLine]", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"mesh", ",", "Automatic", ",", "\"\<show mesh\>\""}], "}"}], 
     ",", 
     RowBox[{"{", 
      RowBox[{"False", ",", "Automatic"}], "}"}], ",", 
     RowBox[{"ControlType", "\[Rule]", "Checkbox"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"ct", ",", "False", ",", "\"\<plot type\>\""}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"True", "\[Rule]", "\"\<2D\>\""}], ",", 
       RowBox[{"False", "\[Rule]", "\"\<3D\>\""}]}], "}"}], ",", 
     RowBox[{"ControlType", "\[Rule]", "SetterBar"}]}], "}"}]}], 
  "]"}]], "Input",
 CellChangeTimes->{
  3.35696210375764*^9, {3.3770265403102922`*^9, 3.37702655108906*^9}, {
   3.377026582966506*^9, 3.3770267393038673`*^9}, {3.3770268376892242`*^9, 
   3.3770268690361643`*^9}, {3.382658752406023*^9, 3.3826587649530582`*^9}, {
   3.3826588434540634`*^9, 3.382658910345545*^9}, {3.3826589636587267`*^9, 
   3.382658993893489*^9}, {3.3826591599424896`*^9, 3.3826592693188896`*^9}, {
   3.382659325772737*^9, 3.3826593547262325`*^9}, {3.3826594126332235`*^9, 
   3.382659458258808*^9}, {3.3826595003374715`*^9, 3.382659502431248*^9}, {
   3.382659552728767*^9, 3.382659553510027*^9}, {3.3826596873086147`*^9, 
   3.3826597315123053`*^9}, {3.3826599045926456`*^9, 
   3.3826599420462503`*^9}, {3.384720736417552*^9, 3.384720766204707*^9}, {
   3.38472079797689*^9, 3.3847207980857763`*^9}, {3.3847208641304827`*^9, 
   3.3847209837093573`*^9}, {3.3866980728732843`*^9, 3.386698108672254*^9}},
 CellID->583658225]
}, Open  ]],

Cell[BoxData[
 TagBox[
  StyleBox[
   DynamicModuleBox[{$CellContext`a$$ = 5., $CellContext`ct$$ = 
    True, $CellContext`f$$ = 3, $CellContext`mesh$$ = 
    Automatic, $CellContext`x0$$ = 13., Typeset`show$$ = True, 
    Typeset`bookmarkList$$ = {}, Typeset`bookmarkMode$$ = "Menu", 
    Typeset`animator$$, Typeset`animvar$$ = 1, Typeset`name$$ = 
    "\"untitled\"", Typeset`specs$$ = {{{
       Hold[$CellContext`f$$], 3, "equation"}, {
      1 -> "wave", 2 -> "sine-Gordon", 3 -> "Wolfram"}}, {{
       Hold[$CellContext`a$$], 5., "initial peak separation"}, 0, 10}, {{
       Hold[$CellContext`x0$$], 13., "solution range"}, 5, 20}, {{
       Hold[$CellContext`mesh$$], Automatic, "show mesh"}, {
      False, Automatic}}, {{
       Hold[$CellContext`ct$$], True, "plot type"}, {
      True -> "2D", False -> "3D"}}}, Typeset`size$$ = {475., {160., 165.}}, 
    Typeset`update$$ = 0, Typeset`initDone$$, Typeset`skipInitDone$$ = 
    True, $CellContext`f$45791$$ = False, $CellContext`a$45792$$ = 
    0, $CellContext`x0$45793$$ = 0, $CellContext`mesh$45794$$ = 
    False, $CellContext`ct$45795$$ = False}, 
    DynamicBox[Manipulate`ManipulateBoxes[
     1, StandardForm, 
      "Variables" :> {$CellContext`a$$ = 5., $CellContext`ct$$ = 
        True, $CellContext`f$$ = 3, $CellContext`mesh$$ = 
        Automatic, $CellContext`x0$$ = 13.}, "ControllerVariables" :> {
        Hold[$CellContext`f$$, $CellContext`f$45791$$, False], 
        Hold[$CellContext`a$$, $CellContext`a$45792$$, 0], 
        Hold[$CellContext`x0$$, $CellContext`x0$45793$$, 0], 
        Hold[$CellContext`mesh$$, $CellContext`mesh$45794$$, False], 
        Hold[$CellContext`ct$$, $CellContext`ct$45795$$, False]}, 
      "OtherVariables" :> {
       Typeset`show$$, Typeset`bookmarkList$$, Typeset`bookmarkMode$$, 
        Typeset`animator$$, Typeset`animvar$$, Typeset`name$$, 
        Typeset`specs$$, Typeset`size$$, Typeset`update$$, Typeset`initDone$$,
         Typeset`skipInitDone$$}, "Body" :> 
      If[$CellContext`ct$$, DensityPlot, Plot3D][
        Evaluate[
         ReplaceAll[
          $CellContext`u[
           
           If[$CellContext`ct$$, $CellContext`x0$$ - $CellContext`t, \
$CellContext`t], $CellContext`x], 
          Quiet[
           NDSolve[
            Evaluate[{D[

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -