# 9月13日 于成都黄龙溪
1 #!/usr/bin/perl # Author : Leon Email: yangli0534@gmail.com
# fdtd simulation , plotting with gnuplot, writting in perl
# perl and gnuplot software packages should be installed before running this program #use Time::HiRes qw(sleep);
#use autodie qw(:all);
print "\@\n";
my $terminal = "";
open GNUPLOT_TERM, "echo 'show terminal;' | gnuplot 2>&1 |";
while (<GNUPLOT_TERM>) {
if (m/terminal type is (\w+)/) {
$terminal=$;
}
}
close GNUPLOT_TERM; # unfortunately, the wxt terminal type does not support positioning.
# hardcode it...
$terminal = "x11"; open my $PIPE ,"| gnuplot " || die "Can't initialize gnuplot number \n"; print $PIPE "set size 0.85, 0.85\n";
print $PIPE "set term png size 600, 400\n"; my $title = "fdtd simulation by leon,yangli0534\\\\@"."gmail.com";
print $PIPE "set terminal gif animate\n";# terminal type: png
print $PIPE "set output \"fdtd_simulation_v0.1.gif\"\n";#output file name
print $PIPE "set title \"{/Times:Italic $title}\"\n";# title name and font
#print $PIPE "set title \"fdtd simulation by leon,yangli0534\\\\@ gmail.com\"\n";# title name and font
print $PIPE "set title font \",15\" norotate tc rgb \"white\"\n";
print $PIPE "unset key\n";
print $PIPE "set tics textcolor rgb \"white\"\n";# text color
print $PIPE "set border lc rgb \"orange\"\n";
print $PIPE "set grid lc rgb\"orange\"\n";
print $PIPE "set object 1 rectangle from screen 0,0 to screen 1,1 fc rgb \"gray10\" behind\n";#background color
print $PIPE "set xlabel\" {/Times:Italic distance: wave length}\" tc rgb \"white\" \n";# xlabel
print $PIPE "set ylabel\"{/Times:Italic amplitude: v}\" tc rgb \"white\"\n";#ylabel
print $PIPE "set autoscale\n"; my $size = ;#physical distance
my @ez;#electric field
my @hy;#magnetic field my $imp0 = 377.0;
#initalization
for (my $i = ; $i < $size; $i++){
$ez[$i] = ;
$hy[$i] = ; }
my $qTime;
my $MaxTime = ;
my $pi = 3.141592563589793;
print $PIPE "set xrange [0:$size-1]\n";
my $mm = ; #do time stepping
for($qTime = ; $qTime < $MaxTime; $qTime+=){ # update magnetic field
for( $mm = ; $mm < $size - ; $mm++){
$hy[$mm] = $hy[$mm] + ($ez[$mm+] - $ez[$mm])/$imp0;
} # update electric field
for( $mm = ; $mm < $size ; $mm++){
$ez[$mm] = $ez[$mm] + ($hy[$mm] - $hy[$mm-])*$imp0;
} if($qTime % == ){ print $PIPE "plot \"-\" w l lw 3 lc rgb \"green\"\n";
my $cnt = ;
for my $elem ( @ez) {
#print " ".$elem;
print $PIPE $cnt." ".$elem."\n";
$cnt += ;
}
print $PIPE "e\n";
}
#hardwire a source
$ez[] = exp(-($qTime - 30.0)*($qTime - 30.0)/);
} #print $PIPE "set terminal x11\n"; print $PIPE "set output\n"; close($PIPE);

fdtd simulation, plotting with gnuplot, writting in perl的更多相关文章

  1. SOS: gnuplot fdtd的一个问题求助 perl vs python

    我用perl和python写了相同功能的一段程序,计算一维fdtd,用gnuplot动态显示,可是python的数据没有显示出来,看横纵坐标的变化数据是正确收到了的,如最后的图片,求大神指点,谢谢. ...

  2. gnuplot Python API

    源文件 #!/usr/bin/env python from os import popen class gnuplot_leon: # Author : Leon Email: yangli0534 ...

  3. FDTD Python API

    源代码 #!/usr/bin/env python from math import exp from gnuplot_leon import * imp0 = 377.0 class fdtd_le ...

  4. 《FDTD electromagnetic field using MATLAB》读书笔记之 Figure 1.14

    背景: 基于公式1.42(Ez分量).1.43(Hy分量)的1D FDTD实现. 计算电场和磁场分量,该分量由z方向的电流片Jz产生,Jz位于两个理想导体极板中间,两个极板平行且向y和z方向无限延伸. ...

  5. post processing in CFD

    post post Table of Contents 1. Post-processing 1.1. Reverse flow 1.1.1. reasons 1.1.2. solutions 1.2 ...

  6. jet flow in a combustion chamber

    Table of Contents 1. contacts 2. Paper digest 2.1. LES vs. RANS 2.2. Dynamics of Transient Fuel Inje ...

  7. 科学计算软件——Octave安装

    Octave是一个旨在提供与Matlab语法兼容的开放源代码科学计算及数值分析的工具,是Matlab商业软件的一个强有力的竞争产品. 参考:[ML:Octave Installation] Gener ...

  8. TFSF边界条件

    待续 %1D FDTD simulation with a simple absorbing boundary condition % and a TFSF boundary between hy[] ...

  9. 怎么学习计算电磁学【QUORA】

    链接 There are several resources. But it depends on what you actually want to learn...Let me explain: ...

随机推荐

  1. PHP异常与错误处理机制

    先区别一下php中错误 与 异常的概念吧 PHP错误:是属于php程序自身的问题,一般是由非法的语法,环境问题导致的,使得编译器无法通过检查,甚至无法运行的情况.平时遇到的warming.notice ...

  2. AngularJs Cookie 的使用

    最新在学习 AngularJs ,发现网上很难搜到 AngularJs.Cookie 教程, 就自己写篇博客,希望能帮到刚学的人. 废话不多说上代码 首先要引用 angular-cookies.js ...

  3. jsoup html采集器

    package com.forex.collect; import java.io.IOException;import java.util.HashMap;import java.util.Iter ...

  4. bootstrap glyphicon图标无法显示

    如果不注意bootstrap引入css和fonts的规范,则可能会导致bootstrap 在显示glyphicon图标时无法正常显示,显示为方框. 此时可搜索bootstrap.css中的.glyph ...

  5. PHP PEAR2

    出错: Pyrus\Installer\Exception: Installation failed Pyrus\AtomicFileTransaction\MultiException: Unabl ...

  6. 常用 windows运行命令

    winver---------检查Windows版本 wmimgmt.msc----打开windows管理体系结构(WMI) wupdmgr--------windows更新程序 wscript--- ...

  7. Ajax的实现

    一.JavaScript的ajax //Ajax var xhr; if(window.XMLHttpRequest){ //除IE外的浏览器 xhr = new XMLHttpRequest() } ...

  8. HTML <!--...--> 注释 、CSS/JS //注释 和 /*.....*/ 注释

    <!-- -->是HTML的注释标签,使用<和>是符合HTML标签语法规则的. /* */(注释代码块).//(注释单行)是CSS和JS的注释标签. 两种注释有各自的使用环境, ...

  9. SharePoint 2013 开启访问请求

    1.通常,我们进入SharePoint 2013站点,如果没权限会提示该站点未被共享,而没有切换账号或者申请访问,实在是很流氓:其实,SharePoint为我们提供了访问请求页面,但是可能需要手动开启 ...

  10. Atitit.为什么小公司也要做高大上开源项目

    Atitit.为什么小公司也要做高大上开源项目 1. 为什么手头有很多加急的事情还要做高大上开源项目??1 2. 从长远看,发展 高大上开源项目计划对于解决我们在应急项目正面临着的种种严峻问题也大有裨 ...