X-Git-Url: https://git.gag.com/?p=debian%2Fatlc;a=blobdiff_plain;f=src%2Fwrite_fields_for_two_conductor_lines.c;fp=src%2Fwrite_fields_for_two_conductor_lines.c;h=c41b4538da88e9ce5839c3b8e2f91935cc6e991f;hp=0000000000000000000000000000000000000000;hb=6b66971c81ba66fc706c04decfa5a69a19e57c4d;hpb=a51f9bc3e458756855df5ab51a7e7ec015a9aebd diff --git a/src/write_fields_for_two_conductor_lines.c b/src/write_fields_for_two_conductor_lines.c new file mode 100644 index 0000000..c41b453 --- /dev/null +++ b/src/write_fields_for_two_conductor_lines.c @@ -0,0 +1,267 @@ +/* atlc - arbitrary transmission line calculator, for the analysis of +transmission lines are directional couplers. + +Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB). + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either package_version 2 +of the License, or (at your option) any later package_version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. + +Dr. David Kirkby, e-mail drkirkby at gmail.com + +*/ + +#include "config.h" + +#include "definitions.h" + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#include "exit_codes.h" + +extern double **Vij; +extern double **Er; +extern unsigned char *bmp_buff; +extern int width, height, errno; +#ifdef WRITE_ODDITY_DATA +extern unsigned char **oddity; +#endif + +/* Write the following files, assuming an input of example.bmp +where example.bmp is a 2 conductor transmission lines. For +3 conductor transmission lines (couplers) the function + + +example.E.bmp Grayscale Bitmap of |E-field|, normallised to 1, +but corrected for Gamma +example.Ex.bmp Colour Bitmap of x-directed E-field, normallised to 1, +but corrected for Gamma +example.Ey.bmp Colour Bitmap of y-directed E-field, normallised to 1, +but corrected for Gamma +example.V.bmp Colour Bitmap of Voltage field, normallised to 1, but +corrected for Gamma +eexample.U.bmp Grayscale bitmap, with just the energy (U=CV^2). + +example.Ex.bin binary file, with just the x-directed E-field +(in volts/pixel) as doubles +example.Ey.bin binary file, with just the y-directed E-field +(in volts/pixel) as doubles +example.E.bin binary file, with just the E-field {sqrt(Ex^2+Ey^2)} +(in volts/pixel) as doubles +example.V.bin binary file, with just the Voltage as doubles +eexample.U.bin binary file, with just the energy (U=CV^2). + +*/ + +extern double image_fiddle_factor; + + +void write_fields_for_two_conductor_lines(char * filename, struct transmission_line_properties data, size_t size) +{ + FILE *Ex_bin_fp=NULL, *Ey_bin_fp=NULL; + FILE *E_bin_fp=NULL, *V_bin_fp, *U_bin_fp=NULL; + FILE *Ex_bmp_fp=NULL, *Ey_bmp_fp=NULL; + FILE *E_bmp_fp=NULL, *V_bmp_fp=NULL, *U_bmp_fp=NULL; +#ifdef WRITE_ODDITY_DATA + FILE *oddity_bmp_fp=NULL; + double odd; +#endif + unsigned char r, g, b; + FILE *permittivity_bin_fp=NULL, *permittivity_bmp_fp=NULL; + struct max_values maximum_values; + int offset=-3, w, h; + double V, E, Ex, Ey, U; + + unsigned char *image_data_Ex=NULL; + unsigned char *image_data_Ey=NULL; + unsigned char *image_data_E=NULL; + unsigned char *image_data_U=NULL; + unsigned char *image_data_V=NULL; + unsigned char *image_data_Er=NULL; +#ifdef WRITE_ODDITY_DATA + unsigned char *image_data_oddity=NULL; +#endif + + + if(data.write_binary_field_imagesQ==TRUE) + { + Ex_bin_fp=get_file_pointer_with_right_filename(filename,".Ex.bin"); + Ey_bin_fp=get_file_pointer_with_right_filename(filename,".Ey.bin"); + E_bin_fp=get_file_pointer_with_right_filename(filename,".E.bin"); + V_bin_fp=get_file_pointer_with_right_filename(filename,".V.bin"); + U_bin_fp=get_file_pointer_with_right_filename(filename,".U.bin"); + permittivity_bin_fp=get_file_pointer_with_right_filename(filename,".Er.bin"); + for(h=height-1;h>=0;h--) + { + for(w=0;w=0;h--) + { + for(w=0;w