/* FDTD-1D-2.2.c 1D FDTD simulation of a lossy dielectric medium */
/* Simulation of a sinusoidal wave or a Gauss pulse transmiting in a lossy dielectric medium exsiting in free space */
/*8888888888888 Using a new formulation and using flux density 8888888888888*/
/* The Fourier Transform has been added */
/* 1D FDTD simulation of a frequency dependent material */
# include <math.h>
# include <stdlib.h>
# include <stdio.h>
# define KE 200 /* KE is the number of cells to be used */
# define NF 10 /* NF is the number of the frequence in fourier transform */
# define Pi 3.1415926
void main ()
{
double ex_low_m1, ex_low_m2,ex_high_m1,ex_high_m2;
double dx[KE],ix[KE],ex[KE],hy[KE],sx[KE];
double ga[KE],gb[KE],gc[KE];
int n, m,k, kc,NSTEPS;
int kstart_dielectric; /* 介质的左边界*/
int kend_dielectric; /* 介质的右边界*/
double T;
double t0, spread,pulse, pulse1, freq_in, pulse2; /*pulse1 is Gauss pulse, Pulse2 is a sinusoidal wave */
double epsilon_r,epsilon_0; /* 介质的相对介电常数 和 真空介电常数*/
double sigma; /* 介质的电导率 */
double ddx, dt; /* The FDTD Cell size and the time interval */
double freq[NF], arg[NF], ampn[NF][KE],phasen[NF][KE];
double real_part[NF][KE], imag_part[NF][KE];
double real_in[NF], imag_in[NF], amp_in[NF], phase_in[NF];
double mag[KE] ;
double tau, chil, del_exp;
FILE *fp ;
/* Initialize */
ddx=0.01; /* Set the cell size to 1cm */
dt=ddx/(2*3e8) ; /* calculate the time step */
epsilon_0=8.85419e-12;
kc=5; /* 激励源所引入的位置 */
t0= 50.0; /* Center of the incident pulse */
spread=10.0; /* Width of the incident pulse */
T=0;
NSTEPS=1;
ex_low_m1=0; /* 在n+1时存储左边界处前一个格点ex[1] 结果 */
ex_low_m2=0; /* 在n+2时存储左边界处前一个格点ex[1] 结果 */
ex_high_m1=0; /* 在n+1时存储右边界处前一个格点ex[KE-2] 结果 */
ex_high_m2=0; /* 在n+2时存储右边界处前一个格点ex[KE-2] 结果 */
for (k=0; k<KE; k++)
{ ga[k]=1.0; /* initialize to free space */
gb[k]=0.;
gc[k]=0; /* initialize to free space */
ex[k]=0.;
hy[k]=0.;
dx[k]=0.;
ix[k]=0;
sx[k]=0;
mag[k]=0;
for (m=0;m<=2;m++)
{ real_part[m][k]=0.; /* Real and imaginary parts of fourier transform */
imag_part[m][k]=0.;
ampn[m][k]=0.; /* Amplituds and phase of the fourier transform */
phasen[m][k]=0.;
}
}
for (m=0;m<=2;m++)
{ real_in[m]=0.; /* Fourier Trans. of input pulse */
imag_in[m]=0.;
}
/* Parameters for the Fourier Transform */
freq[0]=50.e6;
freq[1]=200.e6;
freq[2]=500.e6;
for (m=0;m<=2;m++)
{ arg[m]=2*Pi*freq[m]*dt;
printf("%2d %6.2f MHz %7.5f \n ", m, freq[m]*1e-6,arg[m]);
}
/* These parameters specify the input pulse */
// printf("input frequence (MHz) -->");
// scanf("%lf", &freq_in);
// freq_in=freq_in*1e6;
// printf("%8.0f \n",freq_in);
printf("Dielectric start at kstart_dielectric -->");
scanf("%d", &kstart_dielectric);
printf("Dielectric end at kend_dielectric -->");
scanf("%d", &kend_dielectric);
printf("Epsilon_r -->");
scanf("%lf", &epsilon_r);
printf("Conductivity -->");
scanf("%lf", &sigma);
printf("chil----->");
scanf("%lf", &chil);
tau=1000.; /* Make sure tau is >0. */
if (chil>0.0001)
{printf("tau (in microseconds)--->"); scanf("%lf",&tau); del_exp=exp(-dt/tau);}
printf ("%d %d %f %f %f %f \n", kstart_dielectric,kend_dielectric,epsilon_r, sigma,tau,chil);
tau=1.e-6*tau;
printf("del_exp= %f \n",del_exp) ;
for (k=kstart_dielectric; k<=kend_dielectric;k++)
{ ga[k]=1/(epsilon_r+sigma*dt/epsilon_0+chil*dt/tau);
gb[k]=sigma*dt/epsilon_0; /* initialize to dielectric medium */
gc[k]=chil*dt/tau;
}
for (k=0;k<KE;k++)
{ printf("%2d %4.2f %4.2f \n",k,ga[k],gb[k]); }
/* Main part of program */
while (NSTEPS>0)
{ printf("NSTEPS -->"); /* NSTEPS is the number of times that the Main loop has executed */
scanf("%d", &NSTEPS);
printf ("%d \n", NSTEPS);
printf("程序正在运行,请稍侯! \n");
for (n=1; n<=NSTEPS; n++)
{
T=T+1; /* T keeps track of the total number of times the main loop is executed */
/* Main FDTD Loop */
/* Calculate the Dx field */
for (k=1; k<KE; k++)
{ dx[k]=dx[k]+ 0.5*(hy[k-1]-hy[k]); }
/* Put a sinusoidal wave or the Gauss pulse at the cell kc */
pulse1=exp(-0.5*(pow((t0-T)/spread,2.0)));
// pulse2=sin(2*Pi*freq_in*dt*T);
pulse=pulse1; /* 脉冲的类型由pulse1和pulse2两个变量来选择 */
dx[kc]=dx[kc]+pulse;
printf("%5.1f %f %6.2f \n", T,pulse,dx[kc]);
/* Calculate the Ex from the Dx */
for (k=0;k<KE;k++)
{ ex[k]=ga[k]*(dx[k]-ix[k]-sx[k]);
ix[k]=ix[k]+gb[k]*ex[k];
sx[k]=del_exp*sx[k]+gc[k]*ex[k];
}
/* Calculate the fourier trasform of Ex */
for (k=0;k<KE;k++)
{ for (m=0;m<=2;m++)
{ real_part[m][k]=real_part[m][k]+cos(arg[m]*T)*ex[k];
imag_part[m][k]=imag_part[m][k]-sin(arg[m]*T)*ex[k];
}
}
/* Fourier Transform of the input pulse */
if (T<100)
{
for (m=0;m<=2;m++)
{ real_in[m]=real_in[m]+cos(arg[m]*T)*ex[10];
imag_in[m]=imag_in[m]-sin(arg[m]*T)*ex[10];
}
}
/* Absorbing boundary conditions */
ex[0]=ex_low_m2;
ex_low_m2=ex_low_m1;
ex_low_m1=ex[1];
ex[KE-1]=ex_high_m2;
ex_high_m2=ex_high_m1;
ex_high_m1=ex[KE-2];
/* Calculate the hy field */
for (k=0; k<KE-1;k++)
{ hy[k]=hy[k]+0.5*(ex[k]-ex[k+1]); }
}
/* End of the Main FDTD Loop */
/* At the end of the calculation, print out the Ex and Hy field */
for (k=0; k<KE; k++)
{ printf("%3d %6.2f %6.2f \n", k, ex[k], hy[k]);
}
/* Write the E field out to a file "Ex" */
fp=fopen("Ex.txt","w");
fprintf(fp, "T=%5.0f \n", T);
for (k=0;k<KE;k++)
{
fprintf (fp," %5d %6.2f %6.2f \n", k,dx[k],ex[k]);
}
fclose(fp);
/* Write the H field out to a file "Hy" */
fp=fopen("Hy.txt","w");
fprintf(fp, "T=%5.0f \n", T);
for (k=0;k<KE;k++)
{
fprintf (fp,"%5d %6.2f \n",k, hy[k]);
}
fclose(fp);
printf(" %5.0f \n", T);
/* calculate the amplitude and phase of each frequency */
/* Amplitude and the phase of the input pulse */
for (m=0; m<=2;m++)
{ amp_in[m]=sqrt(pow(imag_in[m],2.0)+pow(real_in[m],2.0));
phase_in[m]=atan2(imag_in[m],real_in[m]);
printf("%d Input pulse: %8.4f %8.4f %8.4f %7.2f \n", m,real_in[m],imag_in[m],amp_in[m],(180.0/Pi)*phase_in[m]);
for(k=0;k<KE;k++)
{ ampn[m][k]=(1.0/amp_in[m]*sqrt(pow(real_part[m][k],2.0)+pow(imag_part[m][k],2.0)));
phasen[m][k]=atan2(imag_part[m][k],real_part[m][k])-phase_in[m];
}
}
/* write the amplitude field out to a files "amp " */
fp=fopen ("amp0.txt","w");
for (k=0;k<KE;k++)
{ fprintf(fp,"%d %8.5f \n ", k,ampn[0][k] ); }
fclose(fp);
fp=fopen ("amp1.txt","w");
for (k=0;k<KE;k++)
{ fprintf(fp,"%d %8.5f \n ", k,ampn[1][k] ); }
fclose(fp);
fp=fopen ("amp2.txt","w");
for (k=0;k<KE;k++)
{ fprintf(fp,"%d %8.5f \n ", k,ampn[2][k] ); }
fclose(fp);
}
printf("程序运行完毕 \n");
}
运行之后出现如下错误
root@gallup-virtual-machine:/home/source# gcc -Wall li.c -o li
li.c:7:6: 警告: ‘main’的返回类型不是‘int’ [-Wmain]root@gallup-virtual-machine:/home/source#
解决方法:
1、 root@gallup-virtual-machine:/home/source# gcc li.c -lm -o li
文章浏览阅读10w+次,点赞173次,收藏149次。接着上一篇OCR所说的,上一篇给大家介绍了tesseract 在命令行的简单用法,当然了要继承到我们的程序中,还是需要代码实现的,下面给大家分享下java实现的例子。拿代码扫描上面的图片,然后输出结果。主要思想就是利用Java调用系统任务。下面是核心代码:package com.zhy.test;import java.io.BufferedReader;import_tesocr jave
文章浏览阅读519次,点赞2次,收藏2次。图片来源:互联网众所周知,中国是智利车厘子最主要的出口对象,占据了其95%的市场份额。智利驻华大使馆商务参赞娜塔曾表示:“2020-2021产季车厘子实现了丰收,预计今年有50万吨左右的车厘子进入中国市场。”自2020年12月中旬开始,智利海运车厘子陆续到达中国,运输成本较此前空运方式大幅下滑。这意味着,国内消费者将能以更低的价格买到车厘子。然而,近日国内已有多地进口车厘子核酸检测结果为阳性,在这种情况下,你还敢大呼“车厘子自由”吗?01 数据获取本文利用Python采集了淘宝网1585.._爬虫 淘宝车厘子
文章浏览阅读1.1k次。OLAP中数据存储的问题OLAP 需要队列进行选择,行式存储按行存数据,使用索引加快对数据的查找(索引包括聚集索引(表记录的排列顺序与索引的排列顺序一致)和非聚簇索引(非聚集索引指定了表中记录的逻辑顺序,但记录的物理顺序和索引的顺序不一致))。这种方式对按列的存储和检索不是很高效,查询某一列数据需要将所有行的数据扫描一次,而且对统计分析也不友好。列式存储原理若使用列式存储可以只用扫描出需要的列,行、列存储的对比。文件格式parquet 文件格式:如下图所示:parquet file = hea_列式存储
文章浏览阅读4.3w次,点赞184次,收藏1.2k次。我们可以把字符串储存在char类型的数组中,如果char类型的数组末尾包含一个表示字符串末尾的空字符\0,则该数组中的内容就构成了一个字符串因为字符串需要用\0结尾,所以在定义字符串的时候,字符数组的长度要预留多一个字节用来存放\0,\0就是数字0例如。_c语言字符串
文章浏览阅读2k次,点赞8次,收藏15次。后台管理项目免不了要做权限控制,常见的分为路由级别和按钮级别,在此主要针对于按钮权限,比如说某个用户或者角色对数据有没有增删改查的权限,例如以下功能,巡查人员可以点击导入和新建,而一般用户只能选择下载模板。在 directives文件夹下分别创建permission、debounce、throttle三个ts文件,分别用于存放权限控制,防抖和节流的业务逻辑,结构清晰,方便维护以及更低的耦合度。在index.ts文件中分别导入每个自定义指令对象,再遍历注册每一个指令。_vue3 v-permission
文章浏览阅读553次。1、maven-dependency-versions-check-plugin, Maven 插件查找依赖版本冲突转载于:https://www.cnblogs.com/yixiu868/p/11583582.html_maven-dependency-versions-check-plugin
文章浏览阅读57次。【1】windows下php运行环境安装【2】php连接MySQL【3】centos7下用yum的方式安装php7.2【4】编译式安装php【5】php日志文件【6】php.ini配置【7】php-fpm.conf重要参数详解【8】扩展mysql【1】windows下php运行环境安装参考连接#下载地址https://windows.php.net/download#php-7.3#解压安装包至任意目录#结合apache或nginx进行配置即可###名词解释...
文章浏览阅读1.3k次。前后端分离之Spring Security Api验证实践为什么需要RESTful重定向问题为什么需要RESTful使用RESTful之前,会发现各种奇葩的url命名,对url的功能经常需要结合源代码来确认,让人头痛,使用RESTful规范之后,很多问题得以解决。仅仅依靠URL和Method就能定为功能。重定向问题需要重新定义逻辑(JDK8推荐使用Lambda表达式)登录 ,默认下..._spring security api
文章浏览阅读10w+次,点赞25次,收藏117次。图像处理之常见二值化方法汇总图像二值化是图像分析与处理中最常见最重要的处理手段,二值处理方法也非常多。越精准的方法计算量也越大。本文主要介绍四种常见的二值处理方法,通常情况下可以满足大多数图像处理的需要。主要本文讨论的方法仅针对RGB色彩空间。 方法一:该方法非常简单,对RGB彩色图像灰度化以后,扫描图像的每个像素值,值小于127的将像素值设为0(黑色),值大于等于12_二值化
文章浏览阅读1.9k次。JAVA程序设计与应用开发(第2版)——《GUI清华大学出版社》_gui开发
文章浏览阅读491次。大家好,给大家分享一下PYTHON实训总结及体会1500字,很多人还不知道这一点。这将使你在做实验时的难度加大。然后两下子就将实验报告做完。但学到的知识与难度成正比。一定要将课本上的知识吃透。【篇一:实验心得体会】就像以前做物理实验一样。在老师讲解时就会听不懂。你要清楚电桥的各种接法。这将使你极大地浪费时间。在做测试技术的实验前。因为这是做实验的基础。_python实验体会
文章浏览阅读9.6k次,点赞9次,收藏117次。特性或指标总述本文将从以下特性进行简单的叙述。结合了《ADC设计基础》和TI的一些教学视频。分辨率转换误差转换速度采样率奈奎斯特采样准则混叠和抗混叠滤波器DNLINL热噪声谐波失真THDSNRENOBSFDRIMD孔径抖动孔径延迟奈奎斯特区补充分辨率一般ADC都说注明是8bit,16bit或者是24bit。这里的数值也就是分辨率的意思。分辨率是衡量A..._adc电流电压零漂值