1 /* 2 * simulation.h 3 * 4 * 5 * Authors: 6 * Richard Hult <rhult@hem.passagen.se> 7 * Ricardo Markiewicz <rmarkie@fi.uba.ar> 8 * Andres de Barbara <adebarbara@fi.uba.ar> 9 * Marc Lorber <lorber.marc@wanadoo.fr> 10 * Guido Trentalancia <guido@trentalancia.com> 11 * 12 * Web page: https://ahoi.io/project/oregano 13 * 14 * Copyright (C) 1999-2001 Richard Hult 15 * Copyright (C) 2003,2004 Ricardo Markiewicz 16 * Copyright (C) 2009-2012 Marc Lorber 17 * Copyright (C) 2017 Guido Trentalancia 18 * 19 * This program is free software; you can redistribute it and/or 20 * modify it under the terms of the GNU General Public License as 21 * published by the Free Software Foundation; either version 2 of the 22 * License, or (at your option) any later version. 23 * 24 * This program is distributed in the hope that it will be useful, 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 * General Public License for more details. 28 * 29 * You should have received a copy of the GNU General Public 30 * License along with this program; if not, write to the 31 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 32 * Boston, MA 02110-1301, USA. 33 */ 34 35 #ifndef __SIMULATION_H 36 #define __SIMULATION_H 37 38 #include <gtk/gtk.h> 39 40 #include "schematic.h" 41 #include "schematic-view.h" 42 43 typedef struct _SimulationData SimulationData; 44 45 typedef enum { 46 ANALYSIS_TYPE_NONE, 47 ANALYSIS_TYPE_OP_POINT, 48 ANALYSIS_TYPE_TRANSIENT, 49 ANALYSIS_TYPE_DC_TRANSFER, 50 ANALYSIS_TYPE_AC, 51 ANALYSIS_TYPE_TRANSFER, 52 ANALYSIS_TYPE_DISTORTION, 53 ANALYSIS_TYPE_NOISE, 54 ANALYSIS_TYPE_POLE_ZERO, 55 ANALYSIS_TYPE_SENSITIVITY, 56 ANALYSIS_TYPE_FOURIER, 57 ANALYSIS_TYPE_UNKNOWN 58 } AnalysisType; 59 60 #define INFINITE 1e50f 61 62 //keep in mind the relation to global variable 63 //const char const *SimulationFunctionTypeString[] 64 //in simulation.c (strings representing the functions in GUI) 65 typedef enum { 66 FUNCTION_SUBTRACT = 0, 67 FUNCTION_DIVIDE 68 } SimulationFunctionType; 69 70 typedef struct _SimulationFunction 71 { 72 SimulationFunctionType type; 73 guint first; 74 guint second; 75 } SimulationFunction; 76 77 struct _SimulationData 78 { 79 AnalysisType type; 80 gint n_variables; 81 gchar **var_names; 82 gchar **var_units; 83 GArray **data; 84 gdouble *min_data; 85 gdouble *max_data; 86 gint got_var; 87 gint got_points; 88 89 // Functions typeof SimulationFunction 90 GList *functions; 91 }; 92 93 typedef struct 94 { 95 SimulationData sim_data; 96 int state; 97 } SimOp; 98 99 typedef struct 100 { 101 SimulationData sim_data; 102 double freq; 103 gint nb_var; 104 } SimFourier; 105 106 typedef struct 107 { 108 SimulationData sim_data; 109 int state; 110 double sim_length; 111 double step_size; 112 } SimTransient; 113 114 typedef struct 115 { 116 SimulationData sim_data; 117 int state; 118 double sim_length; 119 double start, stop; 120 } SimAC; 121 122 typedef struct 123 { 124 SimulationData sim_data; 125 int state; 126 double sim_length; 127 double start, stop, step; 128 } SimDC; 129 130 typedef struct 131 { 132 SimulationData sim_data; 133 int state; 134 double sim_length; 135 double start, stop; 136 } SimNoise; 137 138 typedef union 139 { 140 SimOp op; 141 SimTransient transient; 142 SimFourier fourier; 143 SimAC ac; 144 SimDC dc; 145 SimNoise noise; 146 } Analysis; 147 148 void simulation_show_progress_bar (GtkWidget *widget, SchematicView *sv); 149 gpointer simulation_new (Schematic *sm, Log *logstore); 150 151 #define SIM_DATA(obj) ((SimulationData *)(obj)) 152 #define ANALYSIS(obj) ((Analysis *)(obj)) 153 154 #endif /* __SIMULATION_H */ 155