Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
TOUZE Francois
PSPA
Commits
e9bd4cd1
Commit
e9bd4cd1
authored
Oct 18, 2019
by
TOUZE Francois
Browse files
liste des plots possibles en fn de l'action
parent
2ea3adf6
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
861 additions
and
208 deletions
+861
-208
controller/modules/settingPlots.cpp
controller/modules/settingPlots.cpp
+178
-7
controller/modules/settingPlots.h
controller/modules/settingPlots.h
+6
-0
controller/pspa.py
controller/pspa.py
+26
-0
frontend/src/components/analyze-page/Outputs.vue
frontend/src/components/analyze-page/Outputs.vue
+36
-14
frontend/src/components/analyze-page/Settings.radio.vue
frontend/src/components/analyze-page/Settings.radio.vue
+415
-0
frontend/src/components/analyze-page/Settings.vue
frontend/src/components/analyze-page/Settings.vue
+158
-149
frontend/src/components/simulate-page/ComputingBlocks.vue
frontend/src/components/simulate-page/ComputingBlocks.vue
+31
-36
frontend/src/vuex/mutations.js
frontend/src/vuex/mutations.js
+9
-1
frontend/src/vuex/store.js
frontend/src/vuex/store.js
+2
-1
No files found.
controller/modules/settingPlots.cpp
View file @
e9bd4cd1
...
...
@@ -29,7 +29,7 @@ void pspaplot::settings(string str)
}
else
if
(
item
==
"ellipse$END"
)
{
obj
=
phaseSpace
(
j
,
"end"
);
}
else
{
obj
=
beamParameters
(
j
);
obj
=
plotSelection
(
j
);
//
beamParameters( j );
}
string
fname
=
userDir_
+
"simulator-plot.txt"
;
...
...
@@ -191,6 +191,175 @@ json pspaplot::phaseSpace(json j, string opt)
return
jx
;
}
json
pspaplot
::
plotSelection
(
json
j
)
{
auto
ids
=
j
.
find
(
"plotSimulation"
);
string
item
=
j
.
find
(
"plotItem"
).
value
();
std
::
cout
<<
std
::
boolalpha
;
//cout << "ids is_array? " << ids->is_array() << "\n";
//cout << "ids size? " << ids->size() << "\n";
vector
<
double
>
Xaxis
;
map
<
string
,
vector
<
double
>
>
Ymaps
;
double
shift
=
0.0
;
for
(
json
::
iterator
it
=
ids
->
begin
();
it
!=
ids
->
end
();
++
it
)
{
string
fname
=
*
it
;
fname
=
userDir_
+
fname
+
"-plot.txt"
;
cout
<<
"plotSelection:: OPEN fileName => "
<<
fname
<<
endl
;
std
::
ifstream
ifs
(
fname
);
if
(
!
ifs
.
good
())
{
cout
<<
"plotSelection:: ERROR opening the file "
<<
fname
<<
endl
;
continue
;
}
json
obj
;
ifs
>>
obj
;
ifs
.
close
();
vector
<
double
>
xaxis
=
menu1
(
item
,
obj
);
if
(
xaxis
.
empty
())
continue
;
map
<
string
,
vector
<
double
>
>
ymap
=
menu2
(
item
,
obj
);
if
(
ymap
.
empty
())
continue
;
for
(
auto
&
y
:
ymap
)
{
for
(
int
k
=
0
;
k
<
y
.
second
.
size
();
++
k
)
{
Ymaps
[
y
.
first
].
push_back
(
y
.
second
.
at
(
k
)
);
}
}
for
(
auto
&
x
:
xaxis
)
{
Xaxis
.
push_back
(
x
+
shift
);
}
// pipeline: available for track and twiss
shift
=
xaxis
.
back
();
string
softw
=
obj
.
find
(
"software"
).
value
();
cout
<<
"plotSelection:: software => "
<<
softw
<<
endl
;
string
action
=
obj
.
find
(
"action"
).
value
();
cout
<<
"plotSelection:: action => "
<<
action
<<
endl
;
if
(
action
==
"emitt"
)
break
;
if
(
action
==
"tunes"
)
break
;
if
(
action
==
"matching"
)
break
;
}
json
jx
;
if
(
Xaxis
.
empty
()
||
Ymaps
.
empty
())
{
cout
<<
"pspaplot::bad plot item... check your choice
\n
"
;
jx
=
json
({});
}
else
{
jx
=
lineplots
(
Xaxis
,
Ymaps
);
}
return
jx
;
}
vector
<
double
>
pspaplot
::
menu1
(
string
item
,
json
obj
)
{
string
key
;
if
(
item
==
"tunesVSdelta"
||
item
==
"betaVSdelta"
||
item
==
"alfaVSdelta"
)
{
key
=
"deltap"
;
}
else
if
(
item
==
"tunesVSx"
)
{
key
=
"Ax"
;
}
else
if
(
item
==
"tunesVSy"
)
{
key
=
"Ay"
;
}
else
{
key
=
"zcoor"
;
}
vector
<
double
>
myvector
;
json
::
iterator
kt
=
obj
.
find
(
key
);
if
(
kt
!=
obj
.
end
())
{
for
(
auto
&
el
:
*
kt
)
{
myvector
.
push_back
(
el
);
}
}
return
myvector
;
}
map
<
string
,
vector
<
double
>
>
pspaplot
::
menu2
(
string
item
,
json
obj
)
{
map
<
string
,
vector
<
double
>
>
mymap
;
if
(
item
==
"rms-emittance"
)
{
// valid only for track
mymap
=
{
{
"xemit"
,
vector
<
double
>
()},
{
"yemit"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"beam-size"
)
{
mymap
=
{
{
"xsigma"
,
vector
<
double
>
()},
{
"ysigma"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"bunch-length"
)
{
// valid only for track
mymap
=
{
{
"zsigma"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"energy-spread"
)
{
// valid only for track
mymap
=
{
{
"spread"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"Hx-function"
)
{
// valid only for twiss
mymap
=
{
{
"xHinv"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"betas"
)
{
mymap
=
{
{
"xbeta"
,
vector
<
double
>
()},
{
"ybeta"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"betas&xeta"
)
{
mymap
=
{
{
"xbeta"
,
vector
<
double
>
()},
{
"ybeta"
,
vector
<
double
>
()},
{
"xeta"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"phases"
)
{
// valid only for twiss
mymap
=
{
{
"xmu"
,
vector
<
double
>
()},
{
"ymu"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"chromatics"
)
{
// valid only for twiss
mymap
=
{
{
"wx"
,
vector
<
double
>
()},
{
"wy"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"tunesVSdelta"
)
{
// valid only for tunes
mymap
=
{
{
"qx"
,
vector
<
double
>
()},
{
"qy"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"betaVSdelta"
)
{
// valid only for tunes
mymap
=
{
{
"bx"
,
vector
<
double
>
()},
{
"by"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"alfaVSdelta"
)
{
// valid only for tunes
mymap
=
{
{
"ax"
,
vector
<
double
>
()},
{
"ay"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"tunesVSx"
)
{
// valid only for tunes
mymap
=
{
{
"q1x"
,
vector
<
double
>
()},
{
"q2x"
,
vector
<
double
>
()}
};
}
else
if
(
item
==
"tunesVSy"
)
{
// valid only for tunes
mymap
=
{
{
"q1y"
,
vector
<
double
>
()},
{
"q2y"
,
vector
<
double
>
()}
};
}
else
{
return
mymap
;
}
for
(
auto
it
=
mymap
.
begin
();
it
!=
mymap
.
end
();
)
{
json
::
iterator
kt
=
obj
.
find
(
it
->
first
);
if
(
kt
==
obj
.
end
())
{
it
=
mymap
.
erase
(
it
);
}
else
{
for
(
auto
&
el
:
*
kt
)
{
it
->
second
.
push_back
(
el
);
}
++
it
;
}
}
return
mymap
;
}
json
pspaplot
::
beamParameters
(
json
j
)
{
auto
ids
=
j
.
find
(
"plotSimulation"
);
...
...
@@ -263,6 +432,8 @@ void pspaplot::submenu1(string key,json obj,double& xshift,vector<double>& Xaxis
Xaxis
.
push_back
(
zcoor
);
}
xshift
=
xaxis
->
back
();
}
void
pspaplot
::
submenu2
(
string
key
,
json
obj
,
map
<
string
,
vector
<
double
>
>&
Ymaps
)
...
...
@@ -285,32 +456,32 @@ void pspaplot::submenu2(string key,json obj,map<string,vector<double> >& Ymaps)
menu
(
"spread"
,
obj
,
Ymaps
);
}
if
(
key
==
"H-function"
)
{
// valid only for twiss
if
(
key
==
"H
x
-function"
)
{
// valid only for twiss
menu
(
"xHinv"
,
obj
,
Ymaps
);
}
if
(
key
==
"beta
-function
s"
)
{
if
(
key
==
"betas"
)
{
menu
(
"xbeta"
,
obj
,
Ymaps
);
menu
(
"ybeta"
,
obj
,
Ymaps
);
}
if
(
key
==
"beta&xeta"
)
{
if
(
key
==
"beta
s
&xeta"
)
{
menu
(
"xbeta"
,
obj
,
Ymaps
);
menu
(
"ybeta"
,
obj
,
Ymaps
);
menu
(
"xeta"
,
obj
,
Ymaps
);
}
if
(
key
==
"alfa
-function
s"
)
{
if
(
key
==
"alfas"
)
{
menu
(
"xalfa"
,
obj
,
Ymaps
);
menu
(
"yalfa"
,
obj
,
Ymaps
);
}
if
(
key
==
"phase
-function
s"
)
{
// valid only for twiss
if
(
key
==
"phases"
)
{
// valid only for twiss
menu
(
"xmu"
,
obj
,
Ymaps
);
menu
(
"ymu"
,
obj
,
Ymaps
);
}
if
(
key
==
"chromatic
-function
s"
)
{
// valid only for twiss
if
(
key
==
"chromatics"
)
{
// valid only for twiss
menu
(
"wx"
,
obj
,
Ymaps
);
menu
(
"wy"
,
obj
,
Ymaps
);
menu
(
"xetap"
,
obj
,
Ymaps
);
...
...
controller/modules/settingPlots.h
View file @
e9bd4cd1
...
...
@@ -14,10 +14,16 @@ class pspaplot
string
userDir_
;
json
phaseSpace
(
json
,
string
);
json
plotSelection
(
json
);
vector
<
double
>
menu1
(
string
,
json
);
map
<
string
,
vector
<
double
>
>
menu2
(
string
,
json
);
json
beamParameters
(
json
);
void
submenu1
(
string
,
json
,
double
&
,
vector
<
double
>&
);
void
submenu2
(
string
,
json
,
map
<
string
,
vector
<
double
>
>&
);
void
menu
(
string
,
json
,
map
<
string
,
vector
<
double
>
>&
);
json
lineplots
(
vector
<
double
>
,
map
<
string
,
vector
<
double
>
>
);
...
...
controller/pspa.py
View file @
e9bd4cd1
...
...
@@ -133,6 +133,32 @@ def plots():
'chartConfig'
:
ofi
}
return
jsonify
(
response
)
@
app
.
route
(
'/api/settings'
,
methods
=
[
'GET'
,
'POST'
])
def
settings
():
x
=
request
.
json
ids
=
x
[
'selectedIds'
]
print
(
"/api/settings Ids=> "
,
ids
,
type
(
ids
),
len
(
ids
)
)
z
=
[]
for
id
in
ids
:
d
=
{
"id"
:
id
}
out
=
id
+
"-plot.txt"
fname
=
os
.
path
.
join
(
upath
,
out
)
print
(
"fichier trouvé => "
,
fname
)
if
os
.
path
.
exists
(
fname
):
data
=
json
.
load
(
open
(
fname
)
)
d
[
'software'
]
=
data
[
'software'
]
d
[
'action'
]
=
data
[
'action'
]
z
.
append
(
d
)
response
=
{
'parameters'
:
z
}
return
jsonify
(
response
)
@
app
.
route
(
'/'
,
defaults
=
{
'path'
:
''
})
@
app
.
route
(
'/<path:path>'
)
...
...
frontend/src/components/analyze-page/Outputs.vue
View file @
e9bd4cd1
...
...
@@ -27,52 +27,74 @@
</
template
>
<
script
>
import
axios
from
'
axios
'
;
export
default
{
data
()
{
return
{
Ids
:
[],
selectedIds
:
[]
}
},
created
()
{
console
.
log
(
'
OutPuts=> created
'
);
console
.
log
(
'
OutPuts:: created
'
)
this
.
$store
.
commit
(
'
setSimulationPlot
'
,
''
)
this
.
$store
.
commit
(
'
setAnalyzeParameters
'
,
''
);
this
.
Ids
=
Object
.
keys
(
this
.
$store
.
state
.
simulationResults
);
},
computed
:
{
simulationIds
()
{
console
.
log
(
'
OutPuts=> simulationIds
'
);
const
ids
=
Object
.
keys
(
this
.
$store
.
state
.
simulationResults
);
console
.
log
(
'
Ids proposés :
'
,
ids
)
this
.
selectedIds
=
[]
const
str
=
this
.
$store
.
state
.
projectName
;
var
myArray
=
[];
for
(
var
i
=
0
;
i
<
i
ds
.
length
;
i
++
)
{
if
(
i
ds
[
i
].
indexOf
(
str
)
>=
0
)
myArray
[
i
]
=
i
ds
[
i
];
for
(
var
i
=
0
;
i
<
this
.
I
ds
.
length
;
i
++
)
{
if
(
this
.
I
ds
[
i
].
indexOf
(
str
)
>=
0
)
myArray
.
push
(
this
.
I
ds
[
i
]
)
;
}
console
.
log
(
'
OutPuts::Ids retenus =>
'
,
myArray
)
return
myArray
}
},
methods
:
{
selectedId
()
{
console
.
log
(
'
OutPuts => selectedId
'
);
}
mounted
()
{
console
.
log
(
'
OutPuts:: mounted
'
)
const
path
=
`http://localhost:5000/api/settings`
axios
.
post
(
path
,
{
selectedIds
:
this
.
Ids
}).
then
(
response
=>
{
console
.
log
(
'
OutPuts:: mounted => response
'
)
const
parameters
=
response
.
data
.
parameters
this
.
$store
.
commit
(
'
setAnalyzeParameters
'
,
parameters
);
}).
catch
(
error
=>
{
console
.
log
(
error
)
})
},
methods
:
{
},
watch
:
{
selectedIds
:
function
(
newVal
,
oldVal
)
{
console
.
log
(
'
ancien =>
'
,
oldVal
)
console
.
log
(
'
nouveau
=>
'
,
newVal
)
console
.
log
(
'
Outputs:: watch
=>
'
,
newVal
)
this
.
$store
.
commit
(
'
setSimulationPlot
'
,
newVal
);
}
}
};
</
s
cript
>
<
/
S
cript
>
<
style
scoped
>
...
...
frontend/src/components/analyze-page/Settings.radio.vue
0 → 100644
View file @
e9bd4cd1
<
template
>
<div
id=
"computing-holder"
>
<div
id=
"computing-menu"
class=
"border-bottom border-light d-flex flex-row justify-content-between"
>
<div
id=
"computing-title"
>
<h2
@
click=
"showConfig"
>
Plots
</h2>
</div>
</div>
<div
id=
"computing-block"
v-if=
"isConfig"
>
<div
id=
"radiobox"
>
<div
v-if=
"showOptions.length > 0"
>
<p>
Select a plot option :
</p>
<div
class=
"row"
>
<div
class=
"col"
>
<input
type=
"radio"
id=
"beta"
value=
"Beta"
v-on:click=
"say('beta-functions')"
v-model=
"picked"
>
<label
for=
"beta"
>
beta functions
</label>
</div>
<div
class=
"col"
>
<input
type=
"radio"
id=
"etax"
value=
"Etax"
v-on:click=
"say('beta&xeta')"
v-model=
"picked"
>
<label
for=
"etax"
>
beta
&
etax
</label>
</div>
<div
class=
"col"
>
<input
type=
"radio"
id=
"alfa"
value=
"Alfa"
v-on:click=
"say('alfa-functions')"
v-model=
"picked"
>
<label
for=
"alfa"
>
alpha functions
</label>
</div>
</div>
</div>
<div
v-if=
"showOptions.indexOf('twiss') > -1"
>
<div
class=
"row"
>
<div
class=
"col"
>
<input
type=
"radio"
id=
"phase"
value=
"Phase"
v-on:click=
"say('phase-functions')"
v-model=
"picked"
>
<label
for=
"phase"
>
phase functions
</label>
</div>
<div
class=
"col-8"
>
<input
type=
"radio"
id=
"chromatic"
value=
"Chromatic"
v-on:click=
"say('chromatic-functions')"
v-model=
"picked"
>
<label
for=
"chromatic"
>
chromatic functions
</label>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col"
>
<input
type=
"radio"
id=
"hinvx"
value=
"Hinvx"
v-on:click=
"say('H-function')"
v-model=
"picked"
>
<label
for=
"hinvx"
>
Hx invariant
</label>
</div>
<div
class=
"col-8"
>
<input
type=
"radio"
id=
"sigma"
value=
"Sigma"
v-on:click=
"say('beam-size')"
v-model=
"picked"
>
<label
for=
"sigma"
>
beam size
</label>
</div>
</div>
</div>
<div
v-else-if=
"showOptions.indexOf('tunes') > -1"
>
<div
class=
"row"
>
<div
class=
"col"
>
<input
type=
"radio"
id=
"tunesVSdelta"
value=
"TunesVSdelta"
v-on:click=
"say('tunesVSdelta')"
v-model=
"picked"
>
<label
for=
"tunesVSdelta"
>
tunes vs. Δp/p
</label>
</div>
<div
class=
"col"
>
<input
type=
"radio"
id=
"tunesVSx"
value=
"TunesVSx"
v-on:click=
"say('tunesVSx')"
v-model=
"picked"
>
<label
for=
"tunesVSx"
>
tunes vs. x
</label>
</div>
<div
class=
"col"
>
<input
type=
"radio"
id=
"tunesVSy"
value=
"TunesVSy"
v-on:click=
"say('tunesVSy')"
v-model=
"picked"
>
<label
for=
"tunesVSy"
>
tunes vs. y
</label>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col"
>
<input
type=
"radio"
id=
"betaVSdelta"
value=
"BetaVSdelta"
v-on:click=
"say('betaVSdelta')"
v-model=
"picked"
>
<label
for=
"betaVSdelta"
>
beta vs. Δp/p
</label>
</div>
<div
class=
"col-8"
>
<input
type=
"radio"
id=
"alfaVSdelta"
value=
"AlfaVSdelta"
v-on:click=
"say('alfaVSdelta')"
v-model=
"picked"
>
<label
for=
"alfaVSdelta"
>
alpha vs. Δp/p
</label>
</div>
</div>
</div>
<div
v-else-if=
"showOptions.indexOf('track') > -1"
>
<input
type=
"radio"
id=
"rmsEmit"
value=
"RmsEmit"
v-on:click=
"say('rms-emittance')"
v-model=
"picked"
>
<label
for=
"rmsEmit"
>
transverse emittance
</label>
<input
type=
"radio"
id=
"bunch"
value=
"Bunch"
v-on:click=
"say('bunch-length')"
v-model=
"picked"
>
<label
for=
"bunch"
>
bunch length
</label>
<input
type=
"radio"
id=
"spread"
value=
"Spread"
v-on:click=
"say('energy-spread')"
v-model=
"picked"
>
<label
for=
"spread"
>
energy spread
</label>
<input
type=
"radio"
id=
"sigma"
value=
"Sigma"
v-on:click=
"say('beam-size')"
v-model=
"picked"
>
<label
for=
"sigma"
>
beam size
</label>
</div>
<div
v-else
>
<p>
First, select an output
</p>
</div>
<div
v-if=
"showOptions.indexOf('twiss') > -1 || showOptions.indexOf('track') > -1"
>
<div
class=
"row"
>
<div
class=
"col"
>
<input
type=
"radio"
id=
"one"
value=
"One"
v-on:click=
"say('ellipse$START')"
v-model=
"picked"
>
<label
for=
"one"
>
ellipse at START
</label>
</div>
<div
class=
"col-8"
>
<input
type=
"radio"
id=
"two"
value=
"Two"
v-on:click=
"say('ellipse$END')"
v-model=
"picked"
>
<label
for=
"two"
>
ellipse at END
</label>
</div>
</div>
</div>
</div>
<div
class=
"d-flex flex-row justify-content-between mb-3"
>
<button
size=
"md"
type=
"button"
class=
"white-button ml-4"
>
<router-link
to=
"/Simulate"
>
Back to simulate
</router-link>
</button>
<button
size=
"md"
type=
"button"
id=
"start-simulation"
class=
"btn new-sector border border-success text-white bg-success mr-4"
@
click=
"showPlots"
v-if=
"isDraw"
>
Draw
</button>
<!--
<b-button
size=
"md"
w
type=
"button"
id=
"start-simulation"
class=
"btn new-sector border border-success text-white bg-success mr-4"
v-on:click=
"showConsole"
v-if=
"isSimulationSucceed"
>
Analyze outputs
</b-button>
-->
</div>
</div>
<plots
v-if=
"isPlots"
></plots>
</div>
</
template
>
<
script
>
import
plots
from
'
@/components/analyze-page/Plots.vue
'
;
export
default
{
components
:
{
plots
},
data
()
{
return
{
isConfig
:
true
,
isPlots
:
false
,
isDraw
:
true
,
picked
:
null
,
//myArray: [],
selectedIds
:
[]