# Undulator radiation simulation in SynRad

**URL:** <https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433>\
**Category:** General discussion\
**Created:** [July 6, 2021, 6:40am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433 "2021-07-06T06:40:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/g/a587f6/32.png) [@guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/u/guest_s.talebimotlag)\
**Post date:** [July 6, 2021, 6:40am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/1 "2021-07-06T06:40:31Z")

</div>

Hello

I have some problems with SynRad code for simulating undulator radiation.

I have simulated radiation from insertion devices, undulator, I put sine/cosine type magnetic field in region

I define a periodic magnetic field, with the format : “period dirX dirY dirZ 1 // A1 B1”

For linear polarization, we must set A1 or B1 zero and then run the code, sometimes, I have seen in region info, the end point is not my defined point and there is 2 or 4 point in “number of point” part.

For example my defined starting point was -114cm and end point was 114cm, but in region info part, I see -114 and -113.8 as start and end point. I fond that with changing MAG file the problem could be fixed(changing from sine cosine in mag file, I mean set B1 zero beside A1 zero). But there is another problem. Each time, I have to make new region and saved param ang MAG files could not be used again.

For circular polarization, I need two magnetic field components, one sine and another cosine. I tried to set two components in 1 region and the result was not correct

Please help me to simulate these type of radiations

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [July 7, 2021, 7:00pm UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/2 "2021-07-07T19:00:58Z")

</div>

Hello Saeid,

We need some testing from our side to see how this can be done,  
we’ll get back to you.

Cheers, Marton

---

<div class="post-metadata">

**Author:** ![guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/g/a587f6/32.png) [@guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/u/guest_s.talebimotlag)\
**Post date:** [July 24, 2021, 6:08am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/3 "2021-07-24T06:08:41Z")

</div>

Hello Marton

Thanks for your supporting in this forum

I have used to simulate SynrRad in windows, I examined SynRad in Ubuntu OS.

I dealt with the same issue in Ubuntu OS, too.

I am waiting for your solution.  
Regards

---

<div class="post-metadata">

**Author:** ![rkerseva](https://molflow-forum.web.cern.ch/user_avatar/molflow-forum.web.cern.ch/rkerseva/32/15_2.png) [@rkerseva](https://molflow-forum.web.cern.ch/u/rkerseva)\
**Post date:** [July 24, 2021, 8:39am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/4 "2021-07-24T08:39:04Z")

</div>

Hello Saeid, and thanks for contributing to this forum.  
In order for us to debug the code, if it is a bug that causes your problems, please send the syn7z file to us, so we can actually use exactly the same files and geometry. Also, if you have a description, document or text in an e-mail, of the device you want to simulate (the undulator) then that would be nice to have too.  
Thanks in advance, and good luck with your study/design.

R.

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [July 24, 2021, 9:37am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/5 "2021-07-24T09:37:11Z")

</div>

Sorry Said, I marked your topic to investigate and forgot to reply back, thanknyou for the reminder!

Just a small addition to Roberto’s message that you can upload files directly here (by dragging them in the editor).

I’ll have a look at the .param and .mag then.

Cheers, Marton

---

<div class="post-metadata">

**Author:** ![guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/g/a587f6/32.png) [@guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/u/guest_s.talebimotlag)\
**Post date:** [July 25, 2021, 5:37am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/6 "2021-07-25T05:37:42Z")

</div>

Hello  
I want to explain problems step by step.  
At first, most of the time I deal with this issue in linear polarization: I have defined a region with starting point (-114, 0, 0) and ending point (114, 0, 0), on region info there are (-114, 0, 0) and (-113.97, 0, xxx) as start and end points, as seen in picture.

 ![image](https://molflow-forum.web.cern.ch/uploads/default/original/1X/0f606e8e53ea579555c532de3549ae6caab2eaf1.png)

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [July 25, 2021, 6:22am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/7 "2021-07-25T06:22:08Z")

</div>

Great, thanks for the screenshot!

It happens because you hit the Ymax and Zmax limit at every period (you start the calculation at Y=Z=0, i.e. on the boundary): regions are calculated until _either_ component of the limits is reached.

Set Ymax and Zmax to non-zero (for example 999) and it will work.

Good luck!

---

<div class="post-metadata">

**Author:** ![guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/g/a587f6/32.png) [@guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/u/guest_s.talebimotlag)\
**Post date:** [July 25, 2021, 7:12am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/8 "2021-07-25T07:12:05Z")

</div>

Thanks, Marton so much, I appreciate your help.

In MAG file, I can set Magnetic field as Sinusoidal or Cosinusoidal Field.

Why different choice of field type causes different result?

 ![image](https://molflow-forum.web.cern.ch/uploads/default/original/1X/0b4e780c6a707101262a3c1e28f051241f1bb53b.png)  
 ![image](https://molflow-forum.web.cern.ch/uploads/default/original/1X/087c3502b631c46825e0535affdc47a9a37cb511.png)

---

<div class="post-metadata">

**Author:** ![maarton](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@maarton](https://molflow-forum.web.cern.ch/u/maarton)\
**Post date:** [July 25, 2021, 8:07am UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/9 "2021-07-25T08:07:42Z")

</div>

Sine starts with 0 field, cosine with peak field.

In both cases, the starting direction has to be fine-tuned so that the ceterline of your wiggler/undulator is on the X axis.

You can check the Z coordinate in the View Points window. It should oscillate within a min/max value all along the X coordinate (length) of the region.

Fine tuning is done through adjusting the theta0 value.

---

<div class="post-metadata">

**Author:** ![guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/letter_avatar_proxy/v4/letter/g/a587f6/32.png) [@guest\_s.talebimotlag](https://molflow-forum.web.cern.ch/u/guest_s.talebimotlag)\
**Post date:** [July 25, 2021, 12:35pm UTC](https://molflow-forum.web.cern.ch/t/undulator-radiation-simulation-in-synrad/433/10 "2021-07-25T12:35:58Z")

</div>

Thanks a lot

All the thing that I should do is changing beam start direction to make suitable end point in “Region info” window. Did you mean that?
