Quasistic Cavity Resonance for Ubiquitous Wireless Power Transfer (PDF file)
I'd like to reproduce a program in C language that will derive the efficiency of this paper, but the output will be significantly different from what I wanted.
Personally, I think the integral with vectors per alpha, beta is suspicious.
#define_CRT_SECURE_NO_WARNINGS
#define_USE_MATH_DEFINES
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <math.h>
// function
double hfield_x (double I1, double w1, double x1, double y1) {// Thesis (6) equation (the coefficient of the vector ax in the x-direction of the equation for the magnitude of the magnetic field at the x, y coordinates in the cavity)
double h_x = 0;
int m = 0, l = 0;
for(m=-1;m<=1;m++){
for(l=-1;l<=1;l++){
h_x+=-I1*power(-1,m+l)*(y1-m*w1)/(power(x1-l*w1,2)+power(y1-m*w1,2));
}
}
h_x = h_x/(2*M_PI);
return_x;
}
double hfield_y(double I1, double w1, double x1, double y1) {// Thesis (6) equation (the coefficient of vector ay in the y direction of the equation for the magnitude of the magnetic field at the x, y coordinates in the cavity)
double h_y = 0;
int m = 0, l = 0;
for(m=-1;m<=1;m++){
for(l=-1;l<=1;l++){
h_y+=I1*power(-1,m+l)*(x1-l*w1)/(power(x1-l*w1,2)+power(y1-m*w1,2));
}
}
h_y = h_y/(2*M_PI);
return_y;
}
double alpha (double hfx, double hfy, double myu1) {// Thesis (9) formula for determining the total magnetic energy accumulated in the cavity)
doubleans1=(myu1/2)*(hfx*hfx+hfy*hfy);
returnans1;
}
double beta (double hfx, double hfy, double myu1, double nx1, double ny1) {// Thesis (10) formula (magnetic flux captured by the powered coil)
double ans2 = myu1*(hfx*nx1+hfy*ny1);
returnans2;
}
int main(void){
int x = 0, z = 0; /* orthogonal coordinates */
doubley = 0;
int m=-1,l=-1; /* 計算 Calculated increment */
double I = 0.0, sum = 0.0; // for current reading, for integration
double Q1 = 2130.0, Q2 = 360.0; /* Transmit and receive Q values */
double v=54.0, A=2.720, w=4.90, h=2.30, Aw=0.1650; /* Base Dimensions* /
double Hx = 0.0, Hy = 0.0, hx = 0.0, hy = 0.0; /* magnetic field vectors, for repetition */
double a = 0.0, b = 0.0; /*α, **/
double K = 0.0, X = 0.0; /* ,, **/
double Gmax[10] = {0.0}; /* efficiency*/
double f = 1.32 * power(10,6); // resonant frequency
double myu=4*M_PI*power(10,-7);// permeability
int n = 100; // Integral fineness
double i = 0, j = 0, k = 0, dx = 0, dy = 0, dz = 0, d1 = 0, d2 = 0; // integral increment
double nx = 0.0, ny = 0.0; // unit normal vector
double L2 = 0.0019910; // Receive coil inductance (C2 = 7.3pF)
double sy1 = 0, sy2 = 0, s1 = 0, s2 = 0, sx = 0; // For storing trapezoidal formulas
double xlen[8] = {1.5240000e-01, 4.5720000e-01, 7.6200000e-01, 1.0668000, 1.3716000, 1.6764000, 1.9812000, 2.2860000}; // x coordinates to calculate efficiency
L2 = 1.31e-6;
dx = w/n;
dy = w/n;
dz = h/n;
d1 = Aw/n;
d2 = Aw/n;
printf("Enter I0\n";
scanf("%lf", & I);
for(i=-w/2;i<w/2;i+=dx) {//alpha Calculation
sy1 = 0;
sy2 = 0;
for(j=-w/2;j<w/2;j+=dy){
Hx = 0, Hy = 0;
if(i==0&j==0){
break;
}
else{
s1=(alpha(hfield_x(I,w,i,j),hfield_y(I,w,i,j),myu)+alpha(hfield_x(I,w,i,j+dy),hfield_y(I,w,i,j+dy),myu))/2*dy;
s1=(alpha(hfield_x(I,w,i+dx,j),hfield_y(I,w,i+dx,j),myu)+alpha(hfield_x(I,w,i+dx,j+dy),hfield_y(I,w,i+dx,j+dy),myu))/2*dy;
sy1+=s1;
sy2+=s2;
}
}
sx=(sy1+sy2)/2*dx;
a+=sx;
}
a = a*h;
for(x=0;x<=7;x++){
Hx = 0, Hy = 0, hx = 0, hy = 0;
Hx = hfield_x(I,w,xlen[x],0);
Hy=hfield_y(I,w,xlen[x],0);
nx = 0;
ny = 1;
b = 0;
for(i=xlen[x]-Aw/2; i<xlen[x]+Aw/2;i+=d1) {//beta calculation
Hx = 0, Hy = 0;
sy1 = 0;
sy2 = 0;
s1=(beta(hfield_x(I,w,i,0),hfield_y(I,w,i,0),myu,nx,ny)+beta(hfield_x(I,w,i+d1,0),hfield_y(I,w,i+d1,0),myu,nx,ny))/2*d1;
b+=s1;
}
b=b*Aw;
K=sqrt(2)*2*M_PI*f*b/(4*sqrt(L2*a)); // の formula (8)
X=4*Q1*Q2*power(fabs(K),2)/power(2*M_PI*f,2); // の formula (11)
Gmax[x] = X/power(1+sqrt(1+X), 2); // Gmax formula for calculating efficiency
printf("%.50f\n", Gmax[x]);
}
return 0;
}
I can't respond to the academic aspect, so I hope it will be a hint
Answer.
If you want to write such a complicated program, do a single test using cUnit etc.
It is recommended that you stack it up.
It's a way of making a program as small a collection of functions as possible and accumulating the correct behavior for each function.Also, in order to understand where the value is wrong in the overall behavior, it is effective to use debuggers such as gdb.
Reading academic papers, reading the program presented, and answering where the bug is is a very "heavy" task.The respondents are not particularly well versed in the field like the questioner...In order to make it easier to get answers, why don't you narrow down the scope of your questions?
Well, it's not an answer...
This source compilation doesn't go through??
s51409.c:21:22:error:use of undeclared identifier 'M_PI'
h_x = h_x/(2*M_PI);
Reserved identifier
The problematic name (underscore + identifier is reserved).Be careful.
s51409.c:1:9:warning: macro name is a reserved identifier [-Wreserved-id-macro]
#define_CRT_SECURE_NO_WARNINGS
^
s51409.c:2:9:warning: macro name is a reserved identifier [-Wreserved-id-macro]
#define_USE_MATH_DEFINES
This environment is Linux mint clang version 9.0.0 (trunk354955)
Also, I debug like dichotomy for big programs.
Divide the process in half to see where the behavior goes wrong → Cut the crazy part in half again...like d^^
© 2024 OneMinuteCode. All rights reserved.