-
Notifications
You must be signed in to change notification settings - Fork 0
/
snipps.code-snippets
159 lines (159 loc) · 4.47 KB
/
snipps.code-snippets
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
{
"Header": {
"prefix": "hdr",
"body": [
"$LINE_COMMENT ==============================================================",
"! $1",
"$LINE_COMMENT --------------------------------------------------------------",
"$0"
]
},
"Cite Michelsen-Møllerup": {
"prefix": "mm",
"body": [
"Thermodynamic Models: Fundamental and Computational Aspects, Michael L.",
"!! Michelsen, Jørgen M. Mollerup. Tie-Line Publications, Denmark (2004)",
"!! [doi](http://dx.doi.org/10.1016/j.fluid.2005.11.032)",
]
},
"Use yaeos": {
"scope": "[FortranFreeForm]",
"prefix": "usy",
"body": [
"use yaeos__$1"
]
},
"Documentation": {
"scope": "[FortranFxedForm]",
"prefix": "doc",
"body": [
"!! # ${1:Title}",
"!! ${2:Simple description}",
"!!",
"!! # Description",
"!! ${3:Detailed description}",
"!!",
"!! # Examples",
"!!",
"!! ```fortran",
"!! ${4: A basic code example}",
"!! ```",
"!!",
"!! # References",
"!!",
],
"description": "Documentation template",
},
"Hyperdual-based ArModel": {
"scope": "[FortranFreeForm]",
"prefix": "hdar",
"body": [
"module yaeos__${1:ModelName}",
" use yaeos, only: pr, R",
" use yaeos__autodiff",
"",
" type, extends(ArModelAdiff) :: ${1:ModelName}",
" ${2:ModelParameters}",
" contains",
" procedure :: Ar => Ar",
" procedure :: get_v0 => v0",
" end type ${1:ModelName}",
"",
"contains",
" ",
" type(hyperdual) function Ar(self, n, V, T)",
" class(${1:ModelName}) :: self !! Model",
" type(hyperdual), intent(in) :: n(:) !! Number of moles vector",
" type(hyperdual), intent(in) :: V !! Volume [L/mol]",
" type(hyperdual), intent(in) :: T !! Temperature [K]",
"",
" Ar = Ar function here",
" end function Ar",
"",
" function v0(self, n, P, T)",
" class(${1:ModelName}), intent(in) :: self !! Model",
" real(pr), intent(in) :: n(:) !! Moles vector",
" real(pr), intent(in) :: P !! Pressure [bar]",
" real(pr), intent(in) :: T !! Temperature [K]",
" real(pr) :: v0",
"",
" v0 = 0.001_pr",
" end function v0",
"end module yaeos__${1:ModelName}",
]
},
"FittingProblem": {
"scope": "[FortranFreeForm]",
"prefix": "fp",
"body": [
"module yaeos__fitting_$1",
" use yaeos, only: pr, ArModel, GeModel",
" use yaeos__fitting, only: FittingProblem",
"",
" type, extends(FittingProblem) :: Fit$2",
" contains",
" procedure :: get_model_from_X",
" end type",
"",
"contains",
"",
" type(Fit$2) function get_model_from_X(X) result(model)",
" real(pr), intent(in) :: X(:) !! Vector of fitting parameters",
" class(ArModel), allocatable :: model !! Setted up model",
"",
" $3",
" end function",
"end module",
]
},
"nlopt": {
"scope": "[FortranFreeForm]",
"prefix": "nlopt",
"body": [
"real(pr) function fobj(x, gradient, func_data)",
" real(pr), intent(in out) :: x(:)",
" real(pr), intent(in out), optional :: gradient(:)",
" class(*), intent(in), optional :: func_data",
" ! Here goes the objective function to optimize",
" fobj = 0.0_pr",
"end function",
"",
"real(pr) function optimize(X, func_data) result(y)",
" use nlopt_wrap, only: create, destroy, nlopt_opt, nlopt_algorithm_enum",
" use nlopt_callback, only: nlopt_func, create_nlopt_func",
" real(pr), intent(in) :: X(:)",
" class(*), intent(in), optional :: func_data",
"",
" type(nlopt_opt) :: opt",
" type(nlopt_func) :: f",
" integer :: stat",
"",
" f = create_nlopt_func(fobj, f_data=func_data)",
" opt = create(nlopt_algorithm_enum%NELDER_MEAD, size(X))",
" call opt%set_min_objective(f)",
" call opt%optimize(x, y, stat)",
]
},
"Legacy Makefile": {
"prefix": "makeleg",
"body": [
"# Makefile for legact Fortran project",
"# Replace the files names with CAPS (and their extension) with your files",
"FC=ifort -g -extend-source",
"# Here put the files that are needed to compile, except the program file",
"# which should be in a 'src' folder",
"dependencies:",
"\tmkdir -p obj",
"\t$(FC) -c src/SOMEFILE.f90",
"\t$(FC) -c src/OTHERFILE.f",
"\tmv *.o obj/",
"# Here goes the main program file",
"# which should be in an 'app' folder",
"all: dependencies",
"\t$(FC) -o executable.exe ./app/MAIN_PROGRAM_FILE.for obj/* -qmkl",
"",
"clean:",
"\trm obj/*"
]
}
}