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: ...
随机推荐
- 用Perl编写Apache模块续二 - SVN动态鉴权实现SVNAuth 禅道版
代码地址:https://code.csdn.net/x3dcn/svnauth 以禅道项目管理系统的数据库结构为标准,实现了可用的svn authz验证功能. 以用户名.密码.项目的acl开发程度o ...
- coffeescript 1.8.0 documents
CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque ...
- yii2.0用户登录,退出判断(摘录)
文章来源:http://blog.sina.com.cn/s/blog_88a65c1b0101ix13.html 判断用户是否登录 在 Yii2.0 里面,判断用户是否已经登录,我们用下面的代码即可 ...
- phpcms--使用添加php原生支持
1,phpcms模板中有时候要添加一些php相关变量这个时候要使用原始php的东西,可以如下加入 {php $no_wq_id=$r[id] ;}其中$r[id]是通过{pc:get sql=&quo ...
- ajax跨子域请求的两种现代方法
因为面向互联网的性质,我们公司的大部分系统都采用多子域的方式进行开发和部署,以达到松耦合和分布式的目的,因此子系统间的交互不可避免.虽然通过后台的rpc框架解决了大部分的交互问题,但有些情况下,前端直 ...
- MySQL Cluster配置概述
一. MySQL Cluster概述 MySQL Cluster 是一种技术,该技术允许在无共享的系统中部署“内存中”数据库的 Cluster .通过无共享体系结构,系统能够使用廉价的硬件,而 ...
- SharpGL学习笔记(十八) 解析3ds模型并显示
笔者设想的3D仿真中的元件,是不可能都是“画”出来的.这样就玩复杂了,应该把任务分包出去,让善于制作模型的软件来制作三维模型,我们只需要解析并且显示它即可. 3dsmax制作三维模型的方便,快捷,专业 ...
- 基于UML项目的分析与设计
1,概述 项目中需求和设计的文档是必然的,UML工具可以帮助指导我们从不同的角度去看待一个新的系统,并把这个系统分解剖析出来.本篇文章主要讲述的是如何将UML应用到项目的开发工作中,关于如何学习UML ...
- javascript函数中的三个技巧【三】
技巧三: [函数绑定] 在javascript与DOM交互中经常需要使用函数绑定,定义一个函数然后将其绑定到特定DOM元素或集合的某个事件触发程序上,绑定函数经常和回调函数及事件处理程序一起使用,以便 ...
- Universal-Image-Loader完全解析(上)
Universal-Image-Loader完全解析(上) 基本介绍及使用 大家平时做项目的时候,或多或少都会接触到异步加载图片,或者大量加载图片的问题,而加载图片时候经常会遇到各种问题,如oom,图 ...