Dosya:DoubleWellSolitonAntisoliton.gif
Sayfa içeriği diğer dillerde desteklenmemektedir.
Vikipedi, özgür ansiklopedi
DoubleWellSolitonAntisoliton.gif ((705 × 177 piksel, dosya boyutu: 3,21 MB, MIME tipi: image/gif), döngüye girdi, 800 kare, 48 sn)
Bu dosya Wikimedia Commons'ta bulunmaktadır. Dosyanın açıklaması aşağıda gösterilmiştir. Commons, serbest/özgür telifli medya dosyalarının bulundurulduğu depodur. Siz de yardım edebilirsiniz. |
Özet
AçıklamaDoubleWellSolitonAntisoliton.gif |
English: Solution to in 1+1 dimensionsional spacetime.
v = 0.05, |
Kaynak | Own work by uploader (source code below, click "show" to see) |
Yazar | Cyp |
C++ source code - click on "show" on the right to view |
---|
C++ source code - click on "show" on the right to view |
<nowiki>
#include <cstdio>
#include <stdint.h>
#include <vector>
#include <string>
#include <stdexcept>
#include <cmath>
#include <cassert>
struct Pixel
{
Pixel() { col[0] = 1; col[1] = 1; col[2] = 1; }
Pixel(double r, double g, double b)
{
col[0] = r;
col[1] = g;
col[2] = b;
}
Pixel const &operator +=(Pixel const &p)
{
col[0] += p.col[0];
col[1] += p.col[1];
col[2] += p.col[2];
return *this;
}
Pixel operator -() const
{
return Pixel(-col[0], -col[1], -col[2]);
}
Pixel operator *(float v) const
{
return Pixel(col[0]*v, col[1]*v, col[2]*v);
}
float col[3];
};
inline int quant(int v)
{
//return (v>>4)*0x11;
return v;
}
struct BytePixel
{
BytePixel() { col[0] = 0xFF; col[1] = 0xFF; col[2] = 0xFF; }
BytePixel(Pixel const &p)
{
col[0] = quant(std::max(0, std::min<int>(255, 256*p.col[0])));
col[1] = quant(std::max(0, std::min<int>(255, 256*p.col[1])));
col[2] = quant(std::max(0, std::min<int>(255, 256*p.col[2])));
}
uint8_t col[3];
};
class Image
{
public:
Image(unsigned x, unsigned y, double x1_, double y1_, double x2_, double y2_)
: sx(x), sy(y), x1(x1_), y1(y1_), x2(x2_), y2(y2_), facx(sx/(x2-x1)), facy(sy/(y2-y1)), pixx((x2-x1)/sx), pixy((y2-y1)/sy)
{
data.resize(x*y);
//#pragma omp parallel for
}
void save(std::string const &name)
{
std::vector<BytePixel> byteData(data.begin(), data.end());
std::string filename = name+".ppm";
FILE *f = fopen(filename.c_str(), "wb");
if(f == NULL)
throw std::runtime_error("Couldn't open file \""+filename+"\" for writing.");
std::fprintf(f, "P6\n%u %u\n255\n", sx, sy);
std::fwrite(&byteData[0], 3*sx*sy, 1, f);
std::fclose(f);
}
void addRect(double xa, double ya, double xb, double yb, Pixel const &p)
{
if(xa > x2 || xb < x1 || ya > y2 || yb < y1)
return;
double txa = std::max<double>(0, (xa-x1)*facx);
double tya = std::max<double>(0, (ya-y1)*facy);
double txb = std::min<double>(sx, (xb-x1)*facx);
double tyb = std::min<double>(sy, (yb-y1)*facy);
unsigned uxa = txa;
unsigned uya = tya;
unsigned uxb = std::min<unsigned>(sx-1, txb);
unsigned uyb = std::min<unsigned>(sy-1, tyb);
double xstart = txa-uxa; // Left edge missing in pixels.
double ystart = tya-uya; // Top edge missing in pixels.
double xend = uxb+1-txb; // Right edge missing in pixels.
double yend = uyb+1-tyb; // Bottom edge missing in pixels.
if(uxb < uxa || uyb < uya)
return; // Degenerate rectangle.
for(unsigned y = uya; y != uyb+1; ++y)
{
double yamount = 1;
if(y == uya)
yamount -= ystart;
if(y == uyb)
yamount -= yend;
for(unsigned x = uxa; x != uxb+1; ++x)
{
double xamount = 1;
if(x == uxa)
xamount -= xstart;
if(x == uxb)
xamount -= xend;
data[x + y*sx] += p * (xamount*yamount);
}
}
}
double getDx() const { return pixx; }
double getDy() const { return pixy; }
private:
unsigned sx, sy;
double x1, y1, x2, y2;
double facx, facy;
double pixx, pixy;
std::vector<Pixel> data;
};
void render(Image &img, std::vector<double> const &func, double xa, double xb, Pixel const &p)
{
double dx = (xb-xa)/(func.size()-1);
double lx = img.getDx()*.75; // 1/2 brush width.
double ly = img.getDy()*.75; // 1/2 brush height.
double invRectPix = 1./(1.5*1.5); // Reciprocal area of brush in pixels.
double px = 1/img.getDx();
double py = 1/img.getDy();
double pdx = dx*px; // dx in pixels.
double x = xa+dx*.5;
//printf("test %zu %lf %lf\n", func.size(), lx, ly);
for(unsigned i = 0; i != func.size()-1; ++i)
{
double dy = func[i+1]-func[i];
double pdy = dy*py; // dy in pixels.
double y = (func[i]+func[i+1])*-.5;
img.addRect(x-lx, y-ly, x+lx, y+ly, p*(invRectPix*sqrt(pdx*pdx + pdy*pdy)));
//if(i == func.size()/2)
// printf("%lf %lf %lf %lf %lf\n", x-lx, y-ly, x+lx, y+ly, (invRectPix*sqrt(pdx*pdx + pdy*pdy)));
x += dx;
}
}
void setTanh(std::vector<double> &func, std::vector<double> &dfuncdt, double xa, double xb)
{
double dx = (xb-xa)/(func.size()-1);
double x = xa;
for(unsigned i = 0; i != func.size(); ++i)
{
func[i] = tanh(x);
x += dx;
}
dfuncdt.assign(func.size(), 0);
}
void setDiTanh(std::vector<double> &func, std::vector<double> &dfuncdt, double xa, double xb)
{
double dx = (xb-xa)/(func.size()-1);
double x = xa;
for(unsigned i = 0; i != func.size(); ++i)
{
func[i] = tanh(x+4) - tanh(x-4) - 1;
x += dx;
}
dfuncdt.assign(func.size(), 0);
}
void setDiTanhBump(std::vector<double> &func, std::vector<double> &dfuncdt, double xa, double xb)
{
dfuncdt.assign(func.size(), 0);
double dx = (xb-xa)/(func.size()-1);
double x = xa;
for(unsigned i = 0; i != func.size(); ++i)
{
double v1 = 0.05; // Velocity of leftmost bump. (Exact velocity = sinh(v1).)
double v2 = -0.05; // Velocity of rightmost bump.
double tanh1 = tanh((x+6)*cosh(v1));
double tanh2 = tanh((x-6)*cosh(v2));
func[i] = tanh1 - tanh2 - 1;// + 0.2*exp(-((x+1)*(x+1)));
dfuncdt[i] = (1-tanh1*tanh1)*-sinh(v1) + (1-tanh2*tanh2)*sinh(v2);
x += dx;
}
}
// \mathcal{L} = \partial_\mu\phi\partial^\mu\phi - (\phi^2 - 1)^2
// d²f/dt² = d²f/dx² - 2f(f²-1)²
void stepTime(std::vector<double> &func, std::vector<double> &dfuncdt, double xa, double xb, double dt)
{
assert(func.size() == dfuncdt.size());
double dx = (xb-xa)/(func.size()-1);
double dtinvdx2 = dt/(dx*dx);
dfuncdt[0] = (func[1] - func[0]) / dt;
for(unsigned i = 1; i != func.size()-1; ++i)
dfuncdt[i] += dtinvdx2*(func[i+1] + func[i-1] - 2*func[i]) - 2*dt*func[i]*(func[i]*func[i] - 1);
dfuncdt[func.size()-1] = -(func[func.size()-1] - func[func.size()-2]) / dx;
for(unsigned i = 0; i != func.size(); ++i)
func[i] += dt*dfuncdt[i];
}
int main()
{
double fxa = -208; // Function min x.
double fxb = 208; // Function max x.
unsigned fxr = 20000; // Function resolution.
double imxa = -8; // Display min x.
double imxb = 8; // Display max x.
double imya = -2; // Display min f(x).
double imyb = 2; // Display max f(x).
Image img(801, 201, imxa, imya, imxb, imyb);
img.addRect(-1000, 0-img.getDx(), 1000, 0+img.getDx(), -Pixel(1, 1, 1));
img.addRect(-1000, 1-img.getDx(), 1000, 1+img.getDx(), -Pixel(.5, 1, 1)*.5);
img.addRect(-1000, -1-img.getDx(), 1000, -1+img.getDx(), -Pixel(.5, 1, 1)*.5);
std::vector<double> func(fxr);
std::vector<double> dfuncdt(fxr);
setTanh(func, dfuncdt, fxa, fxb);
render(img, func, fxa, fxb, -Pixel(1, 1, .75));
img.save("soliton");
setDiTanhBump(func, dfuncdt, fxa, fxb);
for(unsigned frame = 0; frame != 800; ++frame)
{
Image imgf(801, 201, imxa, imya, imxb, imyb);
imgf.addRect(-1000, 0-img.getDx(), 1000, 0+img.getDx(), -Pixel(1, 1, 1));
imgf.addRect(-1000, 1-img.getDx(), 1000, 1+img.getDx(), -Pixel(.5, 1, 1)*.5);
imgf.addRect(-1000, -1-img.getDx(), 1000, -1+img.getDx(), -Pixel(.5, 1, 1)*.5);
render(imgf, func, fxa, fxb, -Pixel(1, 1, .75));
for(unsigned i = 0; i != 1000; ++i)
stepTime(func, dfuncdt, fxa, fxb, 1./2000);
//render(imgf, func, -8, 8, -Pixel(1, .75, 1));
//render(imgf, dfuncdt, -8, 8, -Pixel(.75, 1, .75)*.25);
char str[100];
std::sprintf(str, "disoliton%03u", frame);
imgf.save(str);
}
}
</nowiki>
|
Lisanslama
Ben, bu işin telif sahibi, burada işi aşağıdaki lisanslar altında yayımlıyorum:
Bu dosya, Creative Commons Atıf-Benzer Paylaşım 3.0 Taşınmamış lisansı ile lisanslanmıştır
- Şu seçeneklerde özgürsünüz:
- paylaşım – eser paylaşımı, dağıtımı ve iletimi
- içeriği değiştirip uyarlama – eser adaptasyonu
- Aşağıdaki koşullar geçerli olacaktır:
- atıf – Esere yazar veya lisans sahibi tarafından belirtilen (ancak sizi ya da eseri kullanımınızı desteklediklerini ileri sürmeyecek bir) şekilde atıfta bulunmalısınız.
- benzer paylaşım – Maddeyi yeniden karıştırır, dönüştürür veya inşa ederseniz, katkılarınızı orijinal olarak aynı veya uyumlu lisans altında dağıtmanız gerekir.
Bu belgenin GNU Özgür Belgeleme Lisansı, Sürüm 1.2 veya Özgür Yazılım Vakfı tarafından yayımlanan sonraki herhangi bir sürüm şartları altında bu belgenin kopyalanması, dağıtılması ve/veya değiştirilmesi için izin verilmiştir;
Değişmeyen Bölümler, Ön Kapak Metinleri ve Arka Kapak Metinleri yoktur. Lisansın bir kopyası GNU Özgür Belgeleme Lisansı sayfasında yer almaktadır.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
İstediğiniz lisansı seçebilirsiniz.
Bu dosyada gösterilen öğeler
betimlenen
Vikiveri ögesi olmayan bir değer
image/gif
Dosya geçmişi
Dosyanın herhangi bir zamandaki hâli için ilgili tarih/saat kısmına tıklayın.
Tarih/Saat | Küçük resim | Boyutlar | Kullanıcı | Yorum | |
---|---|---|---|---|---|
güncel | 10.05, 30 Mart 2020 | 705 × 177 (3,21 MB) | Bürgerentscheid | resized to fit 100 MP limit | |
21.44, 29 Eylül 2008 | 801 × 201 (2,54 MB) | Cyp | {{Information |Description={{en|1=Solution to <math>\mathcal{L} = \partial_\mu\phi\partial^\mu\phi - (\phi^2 - 1)^2</math> in 1+1 dimensionsional spacetime. v = 0.05,<br /> <math>\phi_0(x, t) = \tanh x</math>,<br /> <math>\phi_\pm(x, t) = \phi_0(x\cosh v |
Dosya kullanımı
Bu görüntü dosyasına bağlantısı olan sayfalar:
Küresel dosya kullanımı
Aşağıdaki diğer vikiler bu dosyayı kullanır:
- en.wikipedia.org üzerinde kullanımı
- ja.wikipedia.org üzerinde kullanımı
- ko.wikipedia.org üzerinde kullanımı
- lt.wikipedia.org üzerinde kullanımı
"https://tr.wikipedia.org/wiki/Dosya:DoubleWellSolitonAntisoliton.gif" sayfasından alınmıştır