summaryrefslogtreecommitdiff
path: root/src/simulation.h
blob: 3f4e23eed87ebf574e2200dcf92095c1e455ae29 (plain)
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
/*
 * simulation.h
 *
 *
 * Authors:
 *  Richard Hult <rhult@hem.passagen.se>
 *  Ricardo Markiewicz <rmarkie@fi.uba.ar>
 *  Andres de Barbara <adebarbara@fi.uba.ar>
 *
 * Web page: http://arrakis.lug.fi.uba.ar/
 *
 * Copyright (C) 1999-2001  Richard Hult
 * Copyright (C) 2003,2004  Ricardo Markiewicz
 *
 * 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 version 2 of the
 * License, or (at your option) any later 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.
 */
#ifndef __SIMULATION_H
#define __SIMULATION_H

#include <gtk/gtk.h>
#include "schematic.h"
#include "schematic-view.h"

typedef struct _SimulationData SimulationData;

typedef enum {
	OP_POINT	,
	TRANSIENT	,
	DC_TRANSFER ,
	AC			,
	TRANSFER	,
	DISTORTION	,
	NOISE		,
	POLE_ZERO	,
	SENSITIVITY ,
	ANALYSIS_UNKNOWN
} AnalysisType;


#define INFINITE 1e50f

typedef enum {
	FUNCTION_MINUS = 0,
	FUNCTION_TRANSFER
} SimulationFunctionType;

typedef struct _SimulationFunction {
	SimulationFunctionType type;
	guint first;
	guint second;
} SimulationFunction;

struct _SimulationData {
	AnalysisType type;
	gboolean	 binary;
	gint		 state;
	gint		 n_variables;
	gint		 n_points;
	gchar	   **var_names;
	gchar	   **var_units;
	GArray	   **data;
	gdouble		*min_data;
	gdouble		*max_data;
	gint		 got_var;
	gint		 got_points;
	gint		 num_data;

	/* Functions  typeof SimulationFunction */
	GList *functions;
};


typedef struct {
	SimulationData sim_data;
	int		 state;
} SimOp;

/* Placeholder for something real later. */
typedef struct {
	SimulationData sim_data;
	double		   freq;
	GList		  *out_var;
} SimFourier;

typedef struct {
	SimulationData sim_data;
	int		 state;
	double	 sim_length;
	double	 step_size;
} SimTransient;

typedef struct {
	SimulationData sim_data;
	int		 state;
	double	 sim_length;
	double	 start,stop;
} SimAC;

typedef struct {
	SimulationData sim_data;
	int		 state;
	double	 sim_length;
	double	 start1,stop1,step1;
	double	 start2,stop2,step2;
} SimDC;


typedef union {
	SimOp		 op;
	SimTransient transient;
	SimFourier	 fourier;
	SimAC		 ac;
	SimDC		 dc;
} Analysis;

void simulation_show (GtkWidget *widget, SchematicView *sv);
gpointer simulation_new (Schematic *sm);
gchar *sim_engine_analysis_name(SimulationData *);

#define SIM_DATA(obj)			   ((SimulationData *)(obj))
#define ANALYSIS(obj)			   ((Analysis *)(obj))

#endif /* __SIMULATION_H */