Conversation
Adding model SerializedMagnetsModel.
…agnets # Conflicts: # pyaml/control/abstract_impl.py # pyaml/lattice/element.py # pyaml/lattice/simulator.py # pyaml/magnet/cfm_magnet.py # pyaml/magnet/magnet.py # pyaml/magnet/octupole.py # pyaml/magnet/quadrupole.py # pyaml/magnet/sextupole.py # pyaml/magnet/skewoctu.py # pyaml/magnet/skewquad.py # pyaml/magnet/skewsext.py # pyaml/magnet/vcorrector.py # tests/external/pyaml_external/external_magnet_model.py
…act as individual magnets.
…een hardware and strength parts in design
|
Side note. I think the difference files in this merge request clearly show that we already need some formatted and pre-commit hooks. @yhidaka made it for https://github.com/python-accelerator-middle-layer/pyaml-cs-oa repository. I would suggest that we simply copy his setup until there are some alternatives (a copier template or something else). |
|
I'm a bit confused with this implementation. But then it is unclear in your serialized_magnets configuration on how you define the names of each set ? Here is what i supposed: - type: pyaml.magnet.serialized_magnet
name: mySeriesOfMagnets
function: B1
elements: # name in the lattice and name of virtual magnet in pyaml
- QD2E-C01
- QD2E-C02
- QD2E-C03
- QF1A-C01
- QF1A-C02
- QF1A-C03
model:
type: pyaml.magnet.linear_serialized_model
calibration_factors: [...] # 1 factor magnet (6)
calibration_offsets: [...] # 1 offset per magnet (6)
unit: m-1
curves: sr/magnet_models/quadcurve.yaml # 1 curve per magnet (6)
matrix: [ [1,1,1,0,0,0]
[0,0,0,1,1,1] ] # For QD2E and QF1A
powerconverters: # 1 ps per set (here 2)
- type: tango.pyaml.attribute
attribute: srmag/vps-qd2/e/current
unit: A
- type: tango.pyaml.attribute
attribute: srmag/vps-qf1/a/current
unit: ABut now, how to access the QD2E family ? When several magnets having different models are powered by a single power supply, then you are forced to work in hardware unit (RW) and update your strengths accordingly (strengths are then read only). It is unclear for me how this is handle ? I also would like also to have a simple implementation with a set of magnet that share the same name in the lattice which is a typical way of using families. It is necessary to have a class that can handle a multiple set of serialized magnets ? only one set is already enough complex... Thanks |
I agree, Guillaume also corrected lots of typos i made (thanks to him) but this make the review more difficult. It would be cool to correct typos, in separate PR that does not affect the code. |
|
To answer your question, @JeanLucPons, it can manage several magnets with separate power supplies to emulate magnets in series. Of course, this is not the main use case, and the matrix is not mandatory. |
Even with different models, you can work with strength, but you will set a strength for a specific magnet, which will provide the corresponding hardware value for the entire series. But it’s true that all magnets are linked through the hardware, so the hardware part is mandatory for magnets in series. |
|
@JeanLucPons, i am adding your example to the tests. |
pyaml has to handle both case. |
|
Ok, I think I need more explanations about magnets sharing the same name. I’d like to have an example for testing. I don’t have enough knowledge on these topics. Would one of you be available to explain how it works to me? |
This quite is easy. You just have to weight each AT magnet strength by element_length/total_length where total length is the sum of all elements length. |
|
We can even go further and handle split magnet with non constant magnet core shape (as we had in the old ESRF DBA) and weight by KL/sum(KL). |
…atch in the lattice. Very first bricks.
|
@gubaidulinvadim |
|
That can wait. But for me, there's no problem applying the pre-commit for formatting. When @gupichon returns to SOLEIL (early January), he will have to merge main into this branch in any case. I could also try to merge the formatting changes here to make his life easier. |
…agnets # Conflicts: # pyaml/control/abstract_impl.py # pyaml/control/controlsystem.py # pyaml/lattice/abstract_impl.py # pyaml/lattice/simulator.py # pyaml/magnet/cfm_magnet.py # pyaml/magnet/linear_cfm_model.py # pyaml/magnet/magnet.py # pyaml/magnet/spline_model.py
|
I've done the merge with the main. |
|
Sorry I didn't have time yesterday to finish the review, may be you have corrected it but there are few issues:
def read_hardware_values(self) -> np.array:
def readback_hardware_values(self) -> np.array:
def send_hardware_values(self, currents: np.array): |
|
It's corrected |
|
Thanks class SerializedMagnetsModel(Element):to class SerializedMagnets(Element):I have to check the lattice abstract implementations , it should be possible to use For the time being in pyAML |
|
Yes, i've seen they updated the RWStrengthScalar object. They migth be used instead. I'm looking to it. |
|
It should be ok now. |
|
It seems fine. |
Description
Handling serialized magnets. Changing one of the serie changes all of them, by passing by the model as the current is common. Specific corrections factors can be set by element.
Related Issue
Features/issues described there are:
Testing
The following tests (compatible with pytest) were added: