aboutsummaryrefslogtreecommitdiff
path: root/src/refine.h
blob: 2646b23e52300f21447afbb50ee033f7a6ce3013 (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
/*
 * refine.h
 *
 * Model Refintement
 *
 * (c) 2006-2007 Thomas White <taw27@cam.ac.uk>
 *
 *  synth2d - Two-Dimensional Crystallographic Fourier Synthesis
 *
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifndef REFINE_H
#define REFINE_H

#include <gtk/gtk.h>

typedef enum {
	COORDINATE_X,
	COORDINATE_Y,
	COORDINATE_Z
} CoordinateSelector;

typedef enum {
	REFINE_SPEC_NONE = 0,
	REFINE_SPEC_X = 1<<0,
	REFINE_SPEC_Y = 1<<1,
	REFINE_SPEC_Z = 1<<2,
	REFINE_SPEC_B = 1<<3,
	REFINE_SPEC_OCC = 1<<4,
	REFINE_SPEC_THICKNESS = 1<<16,
	REFINE_SPEC_INTENSITIES = 1<<18
} RefinementSpec;

typedef enum {
	REFINE_TYPE_NONE = 0,
	REFINE_TYPE_NEIGHBOURSEARCH,
	REFINE_TYPE_BRENT,
	REFINE_TYPE_LMDER,
	REFINE_TYPE_LSQ,
	REFINE_TYPE_CGRAD
} RefinementType;

typedef struct {

	/* Model this refinement refers to */
	struct struct_atomicmodel *model;
	
	/* Refinement specifications */
	RefinementSpec spec;
	RefinementType type;

	/* Dialog box bits */
	GtkWidget *spec_x;
	GtkWidget *spec_y;
	GtkWidget *spec_z;
	GtkWidget *spec_b;
	GtkWidget *spec_thickness;
	GtkWidget *spec_occ;
	GtkWidget *type_neighboursearch;
	GtkWidget *type_brent;
	GtkWidget *type_lmder;
	GtkWidget *type_lsq;
	GtkWidget *type_cgrad;
	GtkWidget *nbsearch_shift;
	GtkWidget *target_amplitudes;
	GtkWidget *target_intensities;
	GtkWidget *stop;
	GtkWidget *go;

	/* Thread control */
	GThread *work_thread;
	unsigned int running;
	unsigned int run_semaphore;
	GStaticMutex display_mutex;
	guint display_callback;
	
} RefinementWindow;

#include "reflist.h"

typedef struct {
	struct struct_atomicmodel *model;
	ReflectionList *reflections;		/* Observations */
	unsigned int cur_mod_atom;
	CoordinateSelector cur_mod_coor;
	double scale;
	RefinementSpec spec;
} RefinementPair;

extern void refine_open(struct struct_atomicmodel *model);

#define LSQ_MSLS_SHIFT 0.000000001
#define MAX_REFINEMENT_ITERATIONS 400

extern void refine_schedule_update(struct struct_atomicmodel *model);

#endif	/* REFINE_H */