Reputation: 1
This is my code...
import java.io.IOException;
import java.util.Scanner;
public class MyFirstClass {
private static Scanner scanner = new Scanner( System.in );
public static void main(String[] args) throws IOException {
System.out.println("Enter the value of Thickness of diaphram ");
double hd = scanner.nextDouble();
System.out.println("Enter the value of side length of diaphram ");
double ad = scanner.nextDouble();
System.out.println("Enter the value of hole fraction of diaphram ");
double kh = scanner.nextDouble();
System.out.println("Enter the value of overlapping Area of diaphram ");
double A = scanner.nextDouble();
System.out.println("Enter the value of air gap of diaphr`enter code here`am ");
double haint = scanner.nextDouble();
double Ed= (160* Math.pow(10, 9));
double vd=(0.2);
int rhod=2300;
double Eo= 8.854*Math.pow(10,-12);
double pi = (3.142857142857412857412857412);
double Fres = (hd/(2*pi*(Math.pow(ad, 2)))*(Math.sqrt((Ed/(0.02436*((1-(Math.pow(vd,2)))*rhod))))));
double D =((Ed *(Math.pow(hd,3))) /(12*(1- (Math.pow(vd, 2)))));
double Vb = 5.225 *(Math.sqrt((Ed*(Math.pow(hd, 3))*(Math.pow(haint, 3)))/((1-(Math.pow(vd, 2)))*Eo*(Math.pow(ad, 4)))));
double M = ((0.00203*Eo*(Math.pow(ad, 4))*(Math.pow(Vb, 2))) / (4*D));
double haeff = (haint/3)*(1+ 2* Math.cos((.33* (Math.acos((1 - ((27*M)))/(Math.pow(haint, 3)))))));
double Cm=Math.abs(((Eo*(1-kh)*A)/(haeff)));
double Se=((0.09274*(Math.pow(ad,2)))*(Math.sqrt(1-(Math.pow(vd, 2))))*(Math.sqrt(haint)))/((Math.sqrt(Ed))*(Math.pow(hd, 1.5))*(Math.sqrt(Eo)));
System.out.println("Fres = "+Fres);
System.out.println("Capacitance = "+Cm);
System.out.println("Sensitivity = "+Se);
}
}
Here I am not getting output for the 'Cm' parameter as it give 'NaN'. Here in the 'haeff' parameter I'm getting a complex value but how to get its value and feed it in 'Cm' parameter.
This is the MATLAB code and it's answer....
clc;
clear all;
hd=input('Thickness of the diameter = ');
ad= input('side length of the diaphram=');
kh= input('hole fraction= ');
A= input('Overlapping area=');
haint= input('Initial air gap between diaphram and back plate=');
Ed= 160* (10^9);
vd=.2;
rhod=2300;
Eo= 8.854 * 10^-12;
% --------------Resonant Frequancy Start line---------------
Fres = (hd/(2*pi*(ad^2)))*(sqrt(Ed/(0.02436*(1-(vd^2))*rhod))) %resonant freq
% --------------Resonant Frequancy End line---------------
% --------------Capacitance Start Line ---------------------
D = (Ed *(hd^3)) /(12*(1- (vd^2)));
Vb = 5.225 *sqrt((Ed*(hd^3)*(haint^3))/((1-(vd^2))*Eo*(ad^4)));
M = ((0.00203*Eo*(ad^4)*(Vb^2)) / (4*D))
haeff = (haint/3)*(1+ 2* cos(.33* acos(1 - ((27*M)/(haint^3)))))
Cm=abs((Eo*(1-kh)*A)/(haeff))%Capacitance
% -----------------Capacitance End Line-------------------
% --------------Sensitivity Start Line ---------------------
Se=(0.09274*(ad^2)*sqrt(1-(vd^2))*sqrt(haint))/((sqrt(Ed)*(hd^1.5))*(sqrt(Eo)))
And it's answer is as follows
Thickness of the diameter = 2.3e-6
side length of the diaphram=2e-6
hole fraction= .8
Overlapping area=3e-6
Initial air gap between diaphram and back plate=.8
Fres =
4.9913e+09
M =
0.0851
haeff =
0.5946 + 0.3110i
Cm =
7.9169e-18
Se =
7.8304e-05
Upvotes: 0
Views: 109
Reputation: 141
Your problem is that in the following line:
double haeff = (haint/3)(1+ 2 Math.cos((.33* (Math.acos((1 - ((27*M)))/(Math.pow(haint, 3)))))));
...the following operation:
(1 - ((27*M)))/(Math.pow(haint, 3))
...is probably returning negative numbers not in the range of [-1, +1]
(I tested with small integers, and it returned -4)
In return the function Math.acos
in the following snippet:
Math.acos((1 - ((27*M)))/(Math.pow(haint, 3)))
...returns NAN
(simple trigonometry). Therefore rendering the value of haeff
to NAN, and by consequence
double Cm=Math.abs(((Eo*(1-kh)*A)/(haeff)));
...which uses the value of haeff
will be NAN
.
Upvotes: 1