1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
| //*Calcul_champ_mag.exe*/
/*on va entrer plusieurs parametres afin de calculer le champ magnetique */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#define M_PI 3.14159265358979323846
#define PI_180 (M_PI / 180.0)
#define rp 3393.5
#define WRITEl1 "%lf %lf %lf %lf %lf %lf %lf \n"
int main(argc, argv)
int argc;
char *argv[];
{
FILE *fout, *f;
char str[200];
double r, theta, phi; //*parametres d'observation */
double alt, lat, lon;
double lat_min, lat_max;
double lon_min, lon_max;
double r_d, theta_d, phi_d; //*parametres du dipole */
double prof_d, lat_d, lon_d;
double Mr_d, Mt_d ,Mp_d;
double l;
double A1, A2, A3;
double B1, B2, B3;
double C1, C2, C3;
double F1, F2, F3;
double Br, Btheta, Bphi;
double x;
double resol;
int i;
double D1,D2,D3;
double prod1, prod2, prod3;
double prod11, prod21, prod31;
double prod111,prod211, prod311;
double F;
double inc;
double l3;
printf("############################################################\n");
printf("Calcul_champ_mag.exe\n\n");
/*printf("\tEntrez les parametres necessaires :\n");*/
printf("Calcul_champ_mag.exe <prof_d> <lat_d> <lon_d> <lat_min> <lat_max> <lon_min> <lon_max> <alt> <Mr_d> <Mt_d> <Mp_d> <inc> <fout> \n");
/* lire les inputs */
prof_d=atof(argv[1]);
scanf("%lf", &prof_d);
lat_d=atof(argv[2]);
scanf("%lf", &lat_d);
lon_d=atof(argv[3]);
scanf("%lf", &lon_d);
lat_min = atof(argv[4]);
scanf("%lf", &lat_min);
lat_max = atof(argv[5]);
scanf("%lf", &lat_max);
lon_min=atof(argv[6]);
scanf("%lf", &lon_min);
lon_max=atof(argv[7]);
scanf("%lf", &lon_max);
alt=atof(argv[8]);
scanf("%lf", &alt);
Mr_d=atof(argv[9]);
scanf("%lf", &Mr_d);
Mt_d=atof(argv[10]);
scanf("%lf", &Mt_d);
Mp_d=atof(argv[11]);
scanf("%lf", &Mp_d);
inc = atof(argv[12]);
scanf("%lf", &inc);
/*modification pour avoir des degres --- a changer*/
/*lat_d = 90.-thetad/PI_180;*/
/*lon_d = phid/PI_180;*/
/*prof_d = rd - rp;*/
theta_d = 90.-(lat_d*PI_180);
phi_d = lon_d*PI_180;
r_d = prof_d+rp;
/* calcul */
for (lat=lat_min; lat<lat_max; lat += inc)
for(lon=lon_min; lon<lon_max; lon +=inc)
{
theta = 90.-(lat*PI_180);
phi = lon*PI_180;
r = alt+rp;
/* calcul des parametres A*/
A1=cos(theta)*cos(theta_d)+sin(theta)*sin(theta_d)*cos(phi-phi_d);
A2=-sin(theta)*cos(theta_d)+cos(theta)*sin(theta_d)*cos(phi-phi_d);
A3=-sin(theta_d)*sin(phi-phi_d);
/*calcul des parametres B*/
B1=cos(theta)*sin(theta_d)-sin(theta)*cos(theta_d)*cos(phi-phi_d);
B2=-sin(theta)*sin(theta_d)-cos(theta)*cos(theta_d)*cos(phi-phi_d);
B3=cos(theta)*sin(phi-phi_d);
/*calcul des parametres C*/
C1=sin(theta)*sin(phi-phi_d);
C2=cos(theta)*sin(phi-phi_d);
C3=cos(phi-phi_d);
/*calcul de l*/
x=acos(cos(theta)*cos(theta_d)+sin(theta)*sin(theta_d)*cos(phi-phi_d));
l=sqrt((r_d*r_d)+(r*r)-2*r_d*r*cos(x));
/*calcul des parametres D*/
D1=r-r_d*A1;
D2=-r_d*A2;
D3=-r_d*A3;
/*calcul des parametres F*/
F1=r*A1-r_d;
F2=-r*B1;
F3=r*C1;
/*calcul prod1 prod2 prod3 pour Br*/
prod1=((3*D1*F1)/(l*l))-A1;
prod2=((3*D1*F2)/(l*l))+B1;
prod3=((3*D1*F3)/(l*l))-C1;
/*calcul prod11 prod21 prod31 pour Btheta*/
prod11=((3*D2*F1)/(l*l))-A2;
prod21=((3*D2*F2)/(l*l))+B2;
prod31=((3*D2*F3)/(l*l))-C2;
/*calcul prod111 prod211 prod311 pour Bphi*/
prod111=((3*D3*F1)/(l*l))-A3;
prod211=((3*D3*F2)/(l*l))+B3;
prod311=((3*D3*F3)/(l*l))-C3;
/*Calcul des composantes du champ magnetique*/
l3=l*l*l;
Br=Mr_d*(prod1/(l3))+Mt_d*(prod2/(l3))+Mp_d*(prod3/(l3));
Btheta=Mr_d*(prod11/(l3))+Mt_d*(prod21/(l3))+Mp_d*(prod31/(l3));
Bphi=Mr_d*(prod111/(l3))+Mt_d*(prod211/(l3))+Mp_d*(prod311/(l3));
/*calcul du champ*/
/* sortie vers fichier */
fprintf(fout, WRITEl1,prof_d,lat_d,lon_d,alt,Br,Btheta,Bphi);
}
} |
Partager