Package cern.accsoft.steering.jmad.model
Interface JMadModel
-
- All Known Implementing Classes:
JMadModelImpl
public interface JMadModel
This is the facade of a JMad - model It provides methods to retrieve values from the model in a save form and also some wrappers to low-level functions which should be used with care.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(JMadModelListener listener)
add a ModelListenervoid
calcOpticsIfDirty()
Calculate the optics if the model became dirty.TfsSummary
calcTwissSummary()
Function issues a single twiss and returns only the summary of the resulting TfsResult.void
call(java.io.File file)
calls a file from madx.void
cleanup()
cleanup all the stuff and free memoryDynapResult
dynap(DynapResultRequest dynapResultRequest, TrackInitialCondition trackInitialCondition)
run a dynamic aperture test with the given initial condition.void
execute(java.lang.String cmd)
executes the given string directly in madx.OpticsDefinition
getActiveOpticsDefinition()
Range
getActiveRange()
RangeDefinition
getActiveRangeDefinition()
Aperture
getAperture()
java.lang.String
getDescription()
JMadKernel
getKernel()
This method retrieves theJMadKernel
to which the model sends its commands.KnobManager
getKnobManager()
java.util.List<MisalignmentConfiguration>
getMisalignments()
NOTE: due to incubation form of this method ONLY QUADRUPOLE elements are extracted!ModelMode
getMode()
JMadModelDefinition
getModelDefinition()
ModelFileFinder
getModelFileFinder()
java.lang.String
getName()
Optic
getOptics()
JMadModelStartupConfiguration
getStartupConfiguration()
StrengthVarSet
getStrengthsAndVars()
StrengthVarManager
getStrengthVarManager()
TwissInitialConditions
getTwissInitialConditions()
double
getValue(java.lang.String valueName)
retrieves the value as defined by its name from madx.java.util.Map<java.lang.String,java.lang.Double>
getValueMap(java.util.Collection<java.lang.String> valueNames)
reads multiple values from the model given by their names to a map.java.util.List<java.lang.Double>
getValues(java.util.List<java.lang.String> valueNames)
reads multiple values from the model which are given by their namesvoid
init()
inits the values.boolean
isInitialized()
void
loadAperture()
loads all the aperture-files to the model apertureMatchResult
match(MatchResultRequest resultRequest)
Run a MadX Matching Command on the JMad Modelvoid
removeListener(JMadModelListener listener)
remove a listenervoid
reset()
resets the model.void
saveBeta(java.lang.String name, java.lang.String location, boolean runDummyTwiss)
Execute the MadX SaveBeta Function, which saves the Optical Functions Values for a given location with the next twiss command inside MadXvoid
setActiveOpticsDefinition(OpticsDefinition newOpticsDefinition)
applies the values of the strengths given by the providedOpticsDefinition
to the model.void
setActiveRangeDefinition(RangeDefinition rangeDefinition)
sets the active range as the range corresponding to the given definitionvoid
setMode(ModelMode modelMode)
void
setStartupConfiguration(JMadModelStartupConfiguration startupConfiguration)
void
setTitle(java.lang.String title)
void
setValue(java.lang.String name, double value)
sets a value as defined by its name directly in madx.void
setValues(java.util.Map<java.lang.String,java.lang.Double> valueNamePairs)
sets a List of value - name pairs directly in madxTrackResult
track(TrackResultRequest trackResultRequest, TrackInitialCondition trackInitialCondition)
Do a tracking with the given initial condition.TfsResult
twiss(TfsResultRequest resultRequest)
runs the twiss with the given given ResultRequest and the initial conditions defined in the model.TfsResult
twiss(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions)
runs the twiss with the given initial conditions.TfsResult
twissToFile(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions, java.io.File tfsFile)
run a twiss with the given initial conditions.TfsResult
twissToFile(TfsResultRequest resultRequest, java.io.File tfsFile)
run a twiss with the given given ResultRequest and the initial conditions defined in the model and write to file.
-
-
-
Method Detail
-
getName
java.lang.String getName()
- Returns:
- the name of the model containing
- ModelDefinition Name
- current Sequence Name
-
getDescription
java.lang.String getDescription()
- Returns:
- the current description of the Model containing
- ModelDefinition Name
- current Sequence Name
- current Range Name
- current Optic Name
-
getModelDefinition
JMadModelDefinition getModelDefinition()
- Returns:
- the model-definition, from which the model was created.
-
setActiveRangeDefinition
void setActiveRangeDefinition(RangeDefinition rangeDefinition) throws JMadModelException
sets the active range as the range corresponding to the given definition- Parameters:
rangeDefinition
- theRangeDefinition
which shall be used to set the newly active range- Throws:
JMadModelException
- if the change of the range fails
-
setActiveOpticsDefinition
void setActiveOpticsDefinition(OpticsDefinition newOpticsDefinition) throws JMadModelException
applies the values of the strengths given by the providedOpticsDefinition
to the model. after loading of the optic it reloads the activeRangeDefinition
. This behavior is necessary, as some of the optics require re-matching of both beams combined. That can result in a different Range being active after the loading of the optics.- Parameters:
newOpticsDefinition
- the optics definition to set as the active one- Throws:
JMadModelException
- in case setting the active range fails
-
getActiveOpticsDefinition
OpticsDefinition getActiveOpticsDefinition()
- Returns:
- the actually used
OpticsDefinition
, ornull
if no optic is loaded.
-
getActiveRangeDefinition
RangeDefinition getActiveRangeDefinition()
- Returns:
- the currently active
RangeDefinition
-
getKnobManager
KnobManager getKnobManager()
- Returns:
- the manager, which contains all the model specific knobs.
-
init
void init() throws JMadModelException
inits the values. Does not initialize the elements!- Throws:
JMadModelException
- if the initialization fails
-
isInitialized
boolean isInitialized()
- Returns:
- true, if the model is correctly initialized, false if not
-
reset
void reset() throws JMadModelException
resets the model. Preserves the elements-state: if they are initialized, they will be reinitialized, otherwise not.- Throws:
JMadModelException
- if the reset fails
-
cleanup
void cleanup() throws JMadModelException
cleanup all the stuff and free memory- Throws:
JMadModelException
- if the cleanup fails
-
twiss
TfsResult twiss(TfsResultRequest resultRequest) throws JMadModelException
runs the twiss with the given given ResultRequest and the initial conditions defined in the model.- Parameters:
resultRequest
- the requested result- Returns:
- the result of the twiss
- Throws:
JMadModelException
- if the twiss calculations fail
-
twissToFile
TfsResult twissToFile(TfsResultRequest resultRequest, java.io.File tfsFile) throws JMadModelException
run a twiss with the given given ResultRequest and the initial conditions defined in the model and write to file.- Parameters:
resultRequest
- the requested resulttfsFile
- the file to write the twiss to- Returns:
- The tfsresult from the twiss
- Throws:
JMadModelException
- if the twiss calculations fail
-
twiss
TfsResult twiss(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions) throws JMadModelException
runs the twiss with the given initial conditions. NOTE: This changes nothing in the state of the model- Parameters:
resultRequest
- the requested resulttwissInitialConditions
- the initial conditions to use- Returns:
- the result of the twiss
- Throws:
JMadModelException
- if the twiss calculations fail
-
twissToFile
TfsResult twissToFile(TfsResultRequest resultRequest, TwissInitialConditions twissInitialConditions, java.io.File tfsFile) throws JMadModelException
run a twiss with the given initial conditions. And write to file. NOTE: This changes nothing in the state of the model- Parameters:
resultRequest
- the requested resulttwissInitialConditions
- the initial conditions to usetfsFile
- the file to write the twiss to- Returns:
- The tfs result, which is also written to the file
- Throws:
JMadModelException
- if the twiss calculations fail
-
getTwissInitialConditions
TwissInitialConditions getTwissInitialConditions()
- Returns:
- the actual twiss initial-conditions. These can be changed in order to start subsequent twiss-commands with the new initial conditions.
-
track
TrackResult track(TrackResultRequest trackResultRequest, TrackInitialCondition trackInitialCondition) throws JMadModelException
Do a tracking with the given initial condition. Note : This changes nothing in the state of the model- Parameters:
trackResultRequest
-trackInitialCondition
-- Returns:
- The result from the tracking
- Throws:
JMadModelException
- if tracking fails
-
dynap
DynapResult dynap(DynapResultRequest dynapResultRequest, TrackInitialCondition trackInitialCondition) throws JMadModelException
run a dynamic aperture test with the given initial condition. Note : This changes nothing to the stat of the model- Parameters:
dynapResultRequest
-trackInitialCondition
-- Returns:
- The result from the dynap command
- Throws:
JMadModelException
- if the command fails
-
calcOpticsIfDirty
void calcOpticsIfDirty() throws JMadModelException
Calculate the optics if the model became dirty.- Throws:
JMadModelException
- if the calculation of the optics fails
-
getOptics
Optic getOptics() throws JMadModelException
- Returns:
- the actual optics values for all elements in the active range.
- Throws:
JMadModelException
- if the calculation of the optics fails
-
addListener
void addListener(JMadModelListener listener)
add a ModelListener- Parameters:
listener
- the listener to add
-
removeListener
void removeListener(JMadModelListener listener)
remove a listener- Parameters:
listener
- the listener to remove
-
getKernel
JMadKernel getKernel()
This method retrieves theJMadKernel
to which the model sends its commands. Use with care!- Returns:
- the kernel of the model.
-
call
void call(java.io.File file)
calls a file from madx.- Parameters:
file
- the file to call
-
execute
void execute(java.lang.String cmd)
executes the given string directly in madx. (must also contain ";" at the end!) Use with care!- Parameters:
cmd
- the string to execute
-
setValue
void setValue(java.lang.String name, double value) throws JMadModelException
sets a value as defined by its name directly in madx.- Parameters:
name
- the name of the value to setvalue
- the value to set- Throws:
JMadModelException
- if setting the value to MadX fails
-
setValues
void setValues(java.util.Map<java.lang.String,java.lang.Double> valueNamePairs) throws JMadModelException
sets a List of value - name pairs directly in madx- Parameters:
valueNamePairs
- the Map containing madx parameter names and values to assign- Throws:
JMadModelException
- if setting the values to MadX fails
-
getValue
double getValue(java.lang.String valueName) throws JMadModelException
retrieves the value as defined by its name from madx.- Parameters:
valueName
- the name of the value- Returns:
- the actual value
- Throws:
JMadModelException
- if the retrieval of the values fails
-
getValues
java.util.List<java.lang.Double> getValues(java.util.List<java.lang.String> valueNames) throws JMadModelException
reads multiple values from the model which are given by their names- Parameters:
valueNames
- the names of the values to read- Returns:
- the values
- Throws:
JMadModelException
- if the retrieval of the values fails
-
getValueMap
java.util.Map<java.lang.String,java.lang.Double> getValueMap(java.util.Collection<java.lang.String> valueNames) throws JMadModelException
reads multiple values from the model given by their names to a map. The non-null map contains the mappings between valueName and read value, if the read operation was successful.- Parameters:
valueNames
- the names of the values to read- Returns:
- a guaranteed non-null map, containing the mappings of the read values
- Throws:
JMadModelException
-
match
MatchResult match(MatchResultRequest resultRequest) throws JMadModelException
Run a MadX Matching Command on the JMad ModelIf no Sequence is specified in the
MatchResultRequest
the actual Sequence will be used for matching as enabled with the last setActiveRange command.After the Matching changes to the model are updated accordingly
- Parameters:
resultRequest
- the Matching Request containing relevant parameters- Returns:
- the
MatchResult
as retrieved from MadX - Throws:
JMadModelException
- if the matching fails
-
saveBeta
void saveBeta(java.lang.String name, java.lang.String location, boolean runDummyTwiss) throws JMadModelException
Execute the MadX SaveBeta Function, which saves the Optical Functions Values for a given location with the next twiss command inside MadX- Parameters:
name
- the MadX internal Name for the SaveBetalocation
- the location in the sequence where to save the Optical Functions ValuesrunDummyTwiss
- if true a 'twiss;' command is send directly after the saveBeta- Throws:
JMadModelException
-
calcTwissSummary
TfsSummary calcTwissSummary() throws JMadModelException
Function issues a single twiss and returns only the summary of the resulting TfsResult. This is nothing else than a shortcut totwiss(TfsResultRequest.createSummaryOnlyRequest()).getSummary()
- Returns:
- the summary part of the actually valid twiss result.
- Throws:
JMadModelException
- if the twiss fails.
-
loadAperture
void loadAperture() throws JMadModelException
loads all the aperture-files to the model aperture- Throws:
JMadModelException
- if loading of the aperture fails
-
getAperture
Aperture getAperture()
- Returns:
- the actually loaded aperture
-
getStrengthsAndVars
StrengthVarSet getStrengthsAndVars()
- Returns:
- the actually valid strengths and variables.
-
getModelFileFinder
ModelFileFinder getModelFileFinder()
- Returns:
- the model file finder
-
getStartupConfiguration
JMadModelStartupConfiguration getStartupConfiguration()
- Returns:
- the startup configuration which will be used when initializing and resetting the model
-
setStartupConfiguration
void setStartupConfiguration(JMadModelStartupConfiguration startupConfiguration)
- Parameters:
startupConfiguration
- the new startup-configuration
-
setMode
void setMode(ModelMode modelMode)
- Parameters:
modelMode
- defines if normal madx or ptc is used
-
getMode
ModelMode getMode()
- Returns:
- the current mode
-
setTitle
void setTitle(java.lang.String title)
- Parameters:
title
- the title to set in MadX for the following twiss-commands
-
getMisalignments
java.util.List<MisalignmentConfiguration> getMisalignments()
NOTE: due to incubation form of this method ONLY QUADRUPOLE elements are extracted!- Returns:
- a complete list of an actual machine imperfections accordingly to the requested definition (see:
Range
addMisalignments(), addMisalignment())
-
getStrengthVarManager
StrengthVarManager getStrengthVarManager()
-
-