using System;
using Science.Mathematics;
using L=Science.Mathematics.PartialDifferentialEquation;
namespace ScienceTest.MathematicsTest.PartialDifferentialEquationTest
{
///
/// LinearEllipticEquationTwoDimensionTest
///
public class LinearEllipticEquation2DTest
{
public LinearEllipticEquation2DTest()
{
}
private string result;
public string Result
{
get{return result;}
}
public void Compute()
{
Function.ToLastType[] cf
= new Function.ToLastType[4];
cf[0] = new Function.ToLastType(Line1);
cf[1] = new Function.ToLastType(Line2);
cf[2] = new Function.ToLastType(Line3);
cf[3] = new Function.ToLastType(Line4);
L.Domain2D xd = new L.Domain2D();
xd.ConditionFunctionsLessThanZero = cf;
xd.LowerBoundOfX = 0.0;
xd.LowerBoundOfY = 0.0;
xd.UpperBoundOfX = 1.0;
xd.UpperBoundOfY = 1.0;
L.LinearEllipticEquation2D eq
= new L.LinearEllipticEquation2D();
L.LinearEllipticEquation2D.Coefficient cxx
= new L.LinearEllipticEquation2D.Coefficient(One);
L.LinearEllipticEquation2D.Coefficient cx
= new L.LinearEllipticEquation2D.Coefficient(Zero);
L.LinearEllipticEquation2D.Coefficient cyy
= new L.LinearEllipticEquation2D.Coefficient(One);
L.LinearEllipticEquation2D.Coefficient cy
= new L.LinearEllipticEquation2D.Coefficient(Zero);
L.LinearEllipticEquation2D.Coefficient cxy
= new L.LinearEllipticEquation2D.Coefficient(Zero);
L.LinearEllipticEquation2D.Coefficient cp
= new L.LinearEllipticEquation2D.Coefficient(Zero);
L.LinearEllipticEquation2D.Coefficient cs
= new L.LinearEllipticEquation2D.Coefficient(Source);
eq.CoefficientOfSecondDerivativeOfX = cxx;
eq.CoefficientOfFirstDerivativeOfX = cx;
eq.CoefficientOfSecondDerivativeOfY = cyy;
eq.CoefficientOfFirstDerivativeOfY = cy;
eq.CoefficientOfDerivativeOfXandY = cxy;
eq.CoefficientOfProportional = cp;
eq.CoefficientOfSourceTerm = cs;
eq.MeshSize = 1.0/32.0;
eq.JacobiRadius = Math.Cos(Math.PI/33.0);
eq.Domain = xd;
eq.SetBoundaryValue(-2.0,-2.0,2.0,2.0,3.0);
eq.Solve();
for(int i = 0; i < eq.Solution.GetLength(0); i++)
{
for(int j = 0; j < eq.Solution.GetLength(1)-1; j++)
result += Convert.ToString(eq.Solution[i,j])+"\t";
result += Convert.ToString(eq.Solution[i,eq.Solution.GetLength(1)-1]);
result +="\r\n";
}
}
private double One(double x, double y)
{
return 1.0;
}
private double Zero(double x, double y)
{
return 0.0;
}
private double Source(double x, double y)
{
if(0.5-0.01 < x && x < 0.5+0.01 && 0.5-0.01 < y && y < 0.5+0.01) return 2.0;
else return 0.0;
}
private double Line1(double x, double y)
{
return -x;
}
private double Line2(double x, double y)
{
return -y;
}
private double Line3(double x, double y)
{
return x-1.0;
}
private double Line4(double x, double y)
{
return y-1.0;
}
}
}
/*
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 2.99999791568514 2.99999583433034 2.9999937515983 2.99999167823136 2.99998961043668 2.99998757060177 2.99998556239574 2.99998362084797 2.9999817616668 2.9999800328625 2.99997846132762 2.99997709718293 2.99997597646335 2.99997514624399 2.99997463205746 2.99997445766832 2.99997463205746 2.99997514624399 2.99997597646335 2.99997709718294 2.99997846132762 2.9999800328625 2.9999817616668 2.99998362084797 2.99998556239574 2.99998757060177 2.99998961043668 2.99999167823136 2.9999937515983 2.99999583433035 2.99999791568514 3
3 2.99999583433035 2.99999166470917 2.99998750109981 2.9999833421059 2.99997920211132 2.99997509798352 2.99997106801086 2.99996714517337 2.99996340182451 2.9999598961999 2.99995671468481 2.99995393596943 2.99995166279093 2.99994996303515 2.99994891745537 2.99994856049082 2.99994891745537 2.99994996303515 2.99995166279093 2.99995393596943 2.99995671468481 2.9999598961999 2.99996340182451 2.99996714517337 2.99997106801086 2.99997509798352 2.99997920211132 2.9999833421059 2.99998750109981 2.99999166470917 2.99999583433035 3
3 2.9999937515983 2.99998750109981 2.9999812476232 2.99997499314366 2.99996875729811 2.99996256197688 2.99995645833454 2.99995050586157 2.99994479995608 2.99993944035426 2.99993455872635 2.99993028179854 2.99992676697917 2.9999241378294 2.99992251178501 2.99992195708351 2.99992251178501 2.9999241378294 2.99992676697917 2.99993028179854 2.99993455872635 2.99993944035426 2.99994479995608 2.99995050586158 2.99995645833454 2.99996256197688 2.99996875729811 2.99997499314366 2.99998124762319 2.99998750109981 2.9999937515983 3
3 2.99999167823136 2.9999833421059 2.99997499314367 2.99996663274679 2.99995826582566 2.99994993733383 2.999941693957 2.99993362737337 2.99992584846302 2.99991851437381 2.99991178560839 2.99990587307527 2.99990097960531 2.99989731195993 2.99989503149135 2.99989425928062 2.99989503149135 2.99989731195993 2.99990097960531 2.99990587307527 2.99991178560839 2.99991851437382 2.99992584846302 2.99993362737337 2.999941693957 2.99994993733383 2.99995826582566 2.99996663274679 2.99997499314366 2.9999833421059 2.99999167823136 3
3 2.99998961043668 2.99997920211132 2.99996875729811 2.99995826582566 2.99994774460588 2.99993722108716 2.99992675732676 2.99991645760677 2.9999064638654 2.99989697125139 2.9998882048265 2.99988043944641 2.99987397240329 2.99986909402119 2.99986604667074 2.99986501327339 2.99986604667075 2.99986909402119 2.99987397240329 2.99988043944641 2.9998882048265 2.99989697125139 2.9999064638654 2.99991645760677 2.99992675732676 2.99993722108716 2.99994774460588 2.99995826582566 2.99996875729811 2.99997920211132 2.99998961043668 3
3 2.99998757060177 2.99997509798352 2.99996256197688 2.99994993733383 2.99993722108716 2.99992443887128 2.99991165992999 2.99989897975701 2.99988658654742 2.99987469816666 2.9998636209369 2.99985370949619 2.99984537647317 2.99983903572326 2.99983505939602 2.99983369932054 2.99983505939603 2.99983903572326 2.99984537647317 2.99985370949619 2.99986362093691 2.99987469816667 2.99988658654742 2.99989897975701 2.99991165993 2.99992443887129 2.99993722108716 2.99994993733383 2.99996256197688 2.99997509798352 2.99998757060177 3
3 2.99998556239574 2.99997106801086 2.99995645833454 2.999941693957 2.99992675732675 2.99991165992999 2.99989644184546 2.99988122771672 2.99986619215172 2.9998516165612 2.99983786256144 2.999825396331 2.99981478375416 2.9998066148438 2.99980144387454 2.99979966933101 2.99980144387455 2.9998066148438 2.99981478375416 2.999825396331 2.99983786256144 2.9998516165612 2.99986619215172 2.99988122771672 2.99989644184546 2.99991165993 2.99992675732676 2.999941693957 2.99995645833454 2.99997106801086 2.99998556239574 3
3 2.99998362084796 2.99996714517337 2.99995050586158 2.99993362737337 2.99991645760677 2.999898979757 2.99988122771672 2.99986328470644 2.99984534583691 2.99982770973681 2.99981080243208 2.99979523084267 2.99978174006943 2.99977119378903 2.99976443398381 2.999762095845 2.99976443398381 2.99977119378903 2.99978174006943 2.99979523084267 2.99981080243209 2.99982770973681 2.99984534583691 2.99986328470644 2.99988122771672 2.99989897975701 2.99991645760677 2.99993362737337 2.99995050586157 2.99996714517337 2.99998362084797 3
3 2.9999817616668 2.99996340182451 2.99994479995608 2.99992584846302 2.9999064638654 2.99988658654742 2.99986619215172 2.99984534583691 2.9998242055082 2.99980306454969 2.99978241810253 2.99976297787859 2.99974576038623 2.99973199841222 2.99972300108414 2.99971985954702 2.99972300108414 2.99973199841223 2.99974576038623 2.99976297787859 2.99978241810253 2.9998030645497 2.99982420550821 2.99984534583691 2.99986619215172 2.99988658654742 2.9999064638654 2.99992584846302 2.99994479995608 2.99996340182451 2.9999817616668 3
3 2.9999800328625 2.9999598961999 2.99993944035426 2.99991851437381 2.99989697125139 2.99987469816666 2.9998516165612 2.9998277097368 2.99980306454969 2.99977794458512 2.99975280721025 2.99972851557181 2.99970632708635 2.99968803626853 2.99967573062395 2.99967134438811 2.99967573062395 2.99968803626853 2.99970632708635 2.99972851557181 2.99975280721026 2.99977794458512 2.9998030645497 2.99982770973681 2.9998516165612 2.99987469816667 2.99989697125139 2.99991851437382 2.99993944035426 2.9999598961999 2.9999800328625 3
3 2.99997846132762 2.99995671468481 2.99993455872635 2.99991178560839 2.9998882048265 2.99986362093691 2.99983786256144 2.99981080243208 2.99978241810253 2.99975280721025 2.99972237433901 2.99969192280745 2.99966300813445 2.99963807458613 2.99962054265223 2.99961404901414 2.99962054265223 2.99963807458613 2.99966300813445 2.99969192280745 2.99972237433901 2.99975280721026 2.99978241810253 2.99981080243209 2.99983786256144 2.99986362093691 2.9998882048265 2.99991178560839 2.99993455872635 2.99995671468481 2.99997846132762 3
3 2.99997709718293 2.99995393596943 2.99993028179854 2.99990587307527 2.99988043944641 2.99985370949619 2.999825396331 2.99979523084267 2.99976297787859 2.99972851557181 2.99969192280745 2.99965380688136 2.99961568997786 2.99958071140171 2.99955430722743 2.99954378141665 2.99955430722743 2.99958071140171 2.99961568997786 2.99965380688136 2.99969192280745 2.99972851557181 2.99976297787859 2.99979523084267 2.999825396331 2.99985370949619 2.99988043944641 2.99990587307527 2.99993028179854 2.99995393596943 2.99997709718294 3
3 2.99997597646335 2.99995166279093 2.99992676697917 2.99990097960531 2.99987397240329 2.99984537647317 2.99981478375416 2.99978174006943 2.99974576038623 2.99970632708634 2.99966300813445 2.99961568997786 2.99956523219152 2.99951477774626 2.99947218077067 2.9994524809034 2.99947218077067 2.99951477774626 2.99956523219152 2.99961568997786 2.99966300813445 2.99970632708635 2.99974576038623 2.99978174006943 2.99981478375416 2.99984537647317 2.99987397240329 2.99990097960531 2.99992676697917 2.99995166279093 2.99997597646335 3
3 2.99997514624399 2.99994996303515 2.9999241378294 2.99989731195993 2.99986909402119 2.99983903572326 2.9998066148438 2.99977119378903 2.99973199841222 2.99968803626853 2.99963807458613 2.99958071140171 2.99951477774626 2.99944097542414 2.99936717777805 2.99932178493599 2.99936717777805 2.99944097542415 2.99951477774626 2.99958071140171 2.99963807458613 2.99968803626853 2.99973199841223 2.99977119378903 2.9998066148438 2.99983903572326 2.99986909402119 2.99989731195993 2.9999241378294 2.99994996303515 2.99997514624399 3
3 2.99997463205746 2.99994891745537 2.99992251178501 2.99989503149135 2.99986604667074 2.99983505939602 2.99980144387455 2.99976443398382 2.99972300108415 2.99967573062395 2.99962054265223 2.99955430722743 2.99947218077067 2.99936717777805 2.99923374660618 2.99910033263767 2.99923374660618 2.99936717777806 2.99947218077067 2.99955430722743 2.99962054265223 2.99967573062395 2.99972300108414 2.99976443398381 2.99980144387455 2.99983505939603 2.99986604667075 2.99989503149135 2.99992251178501 2.99994891745537 2.99997463205746 3
3 2.99997445766832 2.99994856049081 2.99992195708352 2.99989425928062 2.99986501327339 2.99983369932054 2.99979966933101 2.99976209584501 2.99971985954702 2.99967134438811 2.99961404901414 2.99954378141665 2.9994524809034 2.99932178493599 2.99910033263767 2.99861203971057 2.99910033263767 2.99932178493599 2.9994524809034 2.99954378141665 2.99961404901414 2.99967134438811 2.99971985954702 2.99976209584501 2.99979966933101 2.99983369932054 2.99986501327339 2.99989425928062 2.99992195708351 2.99994856049081 2.99997445766832 3
3 2.99997463205746 2.99994891745537 2.99992251178501 2.99989503149135 2.99986604667074 2.99983505939602 2.99980144387455 2.99976443398382 2.99972300108415 2.99967573062395 2.99962054265223 2.99955430722743 2.99947218077067 2.99936717777805 2.99923374660618 2.99910033263767 2.99923374660618 2.99936717777806 2.99947218077067 2.99955430722743 2.99962054265223 2.99967573062395 2.99972300108414 2.99976443398381 2.99980144387455 2.99983505939603 2.99986604667075 2.99989503149135 2.99992251178501 2.99994891745537 2.99997463205746 3
3 2.99997514624399 2.99994996303515 2.9999241378294 2.99989731195993 2.99986909402119 2.99983903572326 2.9998066148438 2.99977119378903 2.99973199841222 2.99968803626853 2.99963807458613 2.99958071140171 2.99951477774626 2.99944097542414 2.99936717777805 2.99932178493599 2.99936717777805 2.99944097542415 2.99951477774626 2.99958071140171 2.99963807458613 2.99968803626853 2.99973199841223 2.99977119378903 2.9998066148438 2.99983903572326 2.99986909402119 2.99989731195993 2.9999241378294 2.99994996303515 2.99997514624399 3
3 2.99997597646335 2.99995166279093 2.99992676697917 2.99990097960531 2.99987397240329 2.99984537647317 2.99981478375416 2.99978174006943 2.99974576038623 2.99970632708634 2.99966300813445 2.99961568997786 2.99956523219152 2.99951477774626 2.99947218077067 2.9994524809034 2.99947218077067 2.99951477774626 2.99956523219152 2.99961568997786 2.99966300813445 2.99970632708635 2.99974576038623 2.99978174006943 2.99981478375416 2.99984537647317 2.99987397240329 2.99990097960531 2.99992676697917 2.99995166279093 2.99997597646335 3
3 2.99997709718293 2.99995393596943 2.99993028179854 2.99990587307527 2.99988043944641 2.99985370949619 2.999825396331 2.99979523084267 2.99976297787859 2.99972851557181 2.99969192280745 2.99965380688136 2.99961568997786 2.99958071140171 2.99955430722743 2.99954378141665 2.99955430722743 2.99958071140171 2.99961568997786 2.99965380688136 2.99969192280745 2.99972851557181 2.99976297787859 2.99979523084267 2.999825396331 2.99985370949619 2.99988043944641 2.99990587307527 2.99993028179854 2.99995393596943 2.99997709718294 3
3 2.99997846132762 2.99995671468481 2.99993455872635 2.99991178560839 2.9998882048265 2.99986362093691 2.99983786256144 2.99981080243208 2.99978241810253 2.99975280721025 2.99972237433901 2.99969192280745 2.99966300813445 2.99963807458613 2.99962054265223 2.99961404901414 2.99962054265223 2.99963807458613 2.99966300813445 2.99969192280745 2.99972237433901 2.99975280721026 2.99978241810253 2.99981080243209 2.99983786256144 2.99986362093691 2.9998882048265 2.99991178560839 2.99993455872635 2.99995671468481 2.99997846132762 3
3 2.9999800328625 2.9999598961999 2.99993944035426 2.99991851437381 2.99989697125139 2.99987469816666 2.9998516165612 2.9998277097368 2.99980306454969 2.99977794458512 2.99975280721025 2.99972851557181 2.99970632708635 2.99968803626853 2.99967573062395 2.99967134438811 2.99967573062395 2.99968803626853 2.99970632708635 2.99972851557181 2.99975280721026 2.99977794458512 2.9998030645497 2.99982770973681 2.9998516165612 2.99987469816667 2.99989697125139 2.99991851437382 2.99993944035426 2.9999598961999 2.9999800328625 3
3 2.9999817616668 2.99996340182451 2.99994479995608 2.99992584846302 2.9999064638654 2.99988658654742 2.99986619215172 2.99984534583691 2.9998242055082 2.99980306454969 2.99978241810253 2.99976297787859 2.99974576038623 2.99973199841222 2.99972300108414 2.99971985954702 2.99972300108414 2.99973199841223 2.99974576038623 2.99976297787859 2.99978241810253 2.9998030645497 2.99982420550821 2.99984534583691 2.99986619215172 2.99988658654742 2.9999064638654 2.99992584846302 2.99994479995608 2.99996340182451 2.9999817616668 3
3 2.99998362084796 2.99996714517337 2.99995050586158 2.99993362737337 2.99991645760677 2.999898979757 2.99988122771672 2.99986328470644 2.99984534583691 2.99982770973681 2.99981080243208 2.99979523084267 2.99978174006943 2.99977119378903 2.99976443398381 2.999762095845 2.99976443398381 2.99977119378903 2.99978174006943 2.99979523084267 2.99981080243209 2.99982770973681 2.99984534583691 2.99986328470644 2.99988122771672 2.99989897975701 2.99991645760677 2.99993362737337 2.99995050586157 2.99996714517337 2.99998362084797 3
3 2.99998556239574 2.99997106801086 2.99995645833454 2.999941693957 2.99992675732675 2.99991165992999 2.99989644184546 2.99988122771672 2.99986619215172 2.9998516165612 2.99983786256144 2.999825396331 2.99981478375416 2.9998066148438 2.99980144387454 2.99979966933101 2.99980144387455 2.9998066148438 2.99981478375416 2.999825396331 2.99983786256144 2.9998516165612 2.99986619215172 2.99988122771672 2.99989644184546 2.99991165993 2.99992675732676 2.999941693957 2.99995645833454 2.99997106801086 2.99998556239574 3
3 2.99998757060177 2.99997509798352 2.99996256197688 2.99994993733383 2.99993722108716 2.99992443887128 2.99991165992999 2.99989897975701 2.99988658654742 2.99987469816666 2.9998636209369 2.99985370949619 2.99984537647317 2.99983903572326 2.99983505939602 2.99983369932054 2.99983505939603 2.99983903572326 2.99984537647317 2.99985370949619 2.99986362093691 2.99987469816667 2.99988658654742 2.99989897975701 2.99991165993 2.99992443887129 2.99993722108716 2.99994993733383 2.99996256197688 2.99997509798352 2.99998757060177 3
3 2.99998961043668 2.99997920211132 2.99996875729811 2.99995826582566 2.99994774460588 2.99993722108716 2.99992675732676 2.99991645760677 2.9999064638654 2.99989697125139 2.9998882048265 2.99988043944641 2.99987397240329 2.99986909402119 2.99986604667074 2.99986501327339 2.99986604667075 2.99986909402119 2.99987397240329 2.99988043944641 2.9998882048265 2.99989697125139 2.9999064638654 2.99991645760677 2.99992675732676 2.99993722108716 2.99994774460588 2.99995826582566 2.99996875729811 2.99997920211132 2.99998961043668 3
3 2.99999167823136 2.9999833421059 2.99997499314367 2.99996663274679 2.99995826582566 2.99994993733383 2.999941693957 2.99993362737337 2.99992584846302 2.99991851437381 2.99991178560839 2.99990587307527 2.99990097960531 2.99989731195993 2.99989503149135 2.99989425928062 2.99989503149135 2.99989731195993 2.99990097960531 2.99990587307527 2.99991178560839 2.99991851437382 2.99992584846302 2.99993362737337 2.999941693957 2.99994993733383 2.99995826582566 2.99996663274679 2.99997499314366 2.9999833421059 2.99999167823136 3
3 2.9999937515983 2.99998750109981 2.9999812476232 2.99997499314366 2.99996875729811 2.99996256197688 2.99995645833454 2.99995050586157 2.99994479995608 2.99993944035426 2.99993455872635 2.99993028179854 2.99992676697917 2.9999241378294 2.99992251178501 2.99992195708351 2.99992251178501 2.9999241378294 2.99992676697917 2.99993028179854 2.99993455872635 2.99993944035426 2.99994479995608 2.99995050586158 2.99995645833454 2.99996256197688 2.99996875729811 2.99997499314366 2.99998124762319 2.99998750109981 2.9999937515983 3
3 2.99999583433035 2.99999166470917 2.99998750109981 2.9999833421059 2.99997920211132 2.99997509798352 2.99997106801086 2.99996714517337 2.99996340182451 2.9999598961999 2.99995671468481 2.99995393596943 2.99995166279093 2.99994996303515 2.99994891745537 2.99994856049082 2.99994891745537 2.99994996303515 2.99995166279093 2.99995393596943 2.99995671468481 2.9999598961999 2.99996340182451 2.99996714517337 2.99997106801086 2.99997509798352 2.99997920211132 2.9999833421059 2.99998750109981 2.99999166470917 2.99999583433035 3
3 2.99999791568514 2.99999583433034 2.9999937515983 2.99999167823136 2.99998961043668 2.99998757060177 2.99998556239574 2.99998362084797 2.9999817616668 2.9999800328625 2.99997846132762 2.99997709718293 2.99997597646335 2.99997514624399 2.99997463205746 2.99997445766832 2.99997463205746 2.99997514624399 2.99997597646335 2.99997709718294 2.99997846132762 2.9999800328625 2.9999817616668 2.99998362084797 2.99998556239574 2.99998757060177 2.99998961043668 2.99999167823136 2.9999937515983 2.99999583433035 2.99999791568514 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
*/