fdtd simulation, plotting with gnuplot, writting in perl
# 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的更多相关文章
- SOS: gnuplot fdtd的一个问题求助 perl vs python
我用perl和python写了相同功能的一段程序,计算一维fdtd,用gnuplot动态显示,可是python的数据没有显示出来,看横纵坐标的变化数据是正确收到了的,如最后的图片,求大神指点,谢谢. ...
- gnuplot Python API
源文件 #!/usr/bin/env python from os import popen class gnuplot_leon: # Author : Leon Email: yangli0534 ...
- FDTD Python API
源代码 #!/usr/bin/env python from math import exp from gnuplot_leon import * imp0 = 377.0 class fdtd_le ...
- 《FDTD electromagnetic field using MATLAB》读书笔记之 Figure 1.14
背景: 基于公式1.42(Ez分量).1.43(Hy分量)的1D FDTD实现. 计算电场和磁场分量,该分量由z方向的电流片Jz产生,Jz位于两个理想导体极板中间,两个极板平行且向y和z方向无限延伸. ...
- 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 ...
- 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 ...
- 科学计算软件——Octave安装
Octave是一个旨在提供与Matlab语法兼容的开放源代码科学计算及数值分析的工具,是Matlab商业软件的一个强有力的竞争产品. 参考:[ML:Octave Installation] Gener ...
- TFSF边界条件
待续 %1D FDTD simulation with a simple absorbing boundary condition % and a TFSF boundary between hy[] ...
- 怎么学习计算电磁学【QUORA】
链接 There are several resources. But it depends on what you actually want to learn...Let me explain: ...
随机推荐
- Android 手机卫士18--流量统计
//获取手机下载流量 //获取流量(R 手机(2G,3G,4G)下载流量) long mobileRxBytes = TrafficStats.getMobileRxBytes(); //获取手机的总 ...
- Socket 学习实例
整理一份Socket代码,整理前辈的代码 http://www.cnblogs.com/yellowapplemylove/archive/2011/04/19/2021586.html 直接贴代码 ...
- 【特别推荐】Node.js 入门教程和学习资源汇总
这篇文章与大家分享一批很有用的 Node.js 入门教程和学习资源.Node 是一个服务器端的 JavaScript 解释器,它将改变服务器应该如何工作的概念.它的目标是帮助程序员构建高度可伸缩的应用 ...
- mac下用ruby安装sass && webstorm下给scss文件添加watch
1.安装rvm 先安装 [Xcode](http://developer.apple.com/xcode/) 开发工具,它将帮你安装好 Unix 环境需要的开发包 sudo curl -L https ...
- SharePoint 2013 术语和术语集介绍
托管元数据是一个集中管理的术语的分层集合,我们可以定义术语和术语集,然后将其用作 SharePoint Server 2013 中项目的属性.简单的说,术语是一个可与 SharePoint Serve ...
- [C/C++] VS 2015 C++ 插件
Visual Studio2015 Community一些必备插件 ReSharper C++ 各种语言版本的代码重构,代码风格,代码修正功能,非常强大,可惜不是免费的,不过好在可以破解呢. Vias ...
- android studio问题rendering problems no render target selected
activity_main.xml选择Design显示rendering problems no render target selected 在stackOverflow上找到了答案: You ne ...
- iOS自定义AlertView 与 ActionSheet 遮罩提示+弹出动画
产品大人总是能够想到很多让人欣慰的点子,基本所有能提示的地方都要很多文案啊图片之类 由此封装了一个半透明黑色遮罩的alert类(假装有图.jpg) 代码略糙,just share (逃 下载链接
- Struts2(十五)实现文件上传
一.导入包 需要将commons-fileupload和commons-io包和struts包一起导入 实现步骤: 在Jsp页面实现客户端选择上传文件 配置Struts.xml,拦截器会自动接收上传的 ...
- centos查看硬件信息
服务器硬件信息常见, 是经常要操作的事: 下面分享一些常见的硬件查看命令: 1.centos 下查看硬件信息内容非常全面. CentOS常用命令查看cpu more /proc/cpuinfo 2.C ...