# Regions permittivity

**URL:** https://community.freefem.org/t/regions-permittivity/830
**Category:** General Discussion
**Created:** [March 3, 2021, 6:25pm UTC](https://community.freefem.org/t/regions-permittivity/830 "2021-03-03T18:25:59Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![niaa](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@niaa](https://community.freefem.org/u/niaa)
#### Post date: [March 3, 2021, 6:25pm UTC](https://community.freefem.org/t/regions-permittivity/830/1 "2021-03-03T18:25:59Z")

</div>

Hello colleagues,

I have a domain with two different regions ( region 1 and region 2). I need to define a function for permittivity so that in region 1 it considers the permittivity of air but in the region 2 another permittivity.  
Does this command is proper to get this goal:

real ep = 12;  
real er= 1;  
func erregion = (region == 1 ? er : ep);

thanks for your help.

---

<div class="post-metadata">

### Author: ![mrbenson](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@mrbenson](https://community.freefem.org/u/mrbenson)
#### Post date: [March 4, 2021, 7:17pm UTC](https://community.freefem.org/t/regions-permittivity/830/2 "2021-03-04T19:17:32Z")

</div>

func erregion = er\*(region == 1) + ep\*(region==2);

---

<div class="post-metadata">

### Author: ![niaa](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@niaa](https://community.freefem.org/u/niaa)
#### Post date: [March 4, 2021, 8:04pm UTC](https://community.freefem.org/t/regions-permittivity/830/3 "2021-03-04T20:04:36Z")

</div>

thanks, but I have tried this command before, but it doesn’t give me the answer…  
the one that I suggested is wrong?

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [March 6, 2021, 11:23am UTC](https://community.freefem.org/t/regions-permittivity/830/4 "2021-03-06T11:23:14Z")

</div>

Use a piecewise constant function.

```auto
fespace Ph(Th, P0);
Ph erregion = (region == 1 ? er : ep);

```

---

<div class="post-metadata">

### Author: ![niaa](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@niaa](https://community.freefem.org/u/niaa)
#### Post date: [March 7, 2021, 6:12pm UTC](https://community.freefem.org/t/regions-permittivity/830/5 "2021-03-07T18:12:03Z")

</div>

I get error via this command;  
can you please help me in defining proper command for permittivity of a domain with 2 regions ? Its like considering a dielectric object in free space.

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [March 7, 2021, 6:16pm UTC](https://community.freefem.org/t/regions-permittivity/830/6 "2021-03-07T18:16:27Z")

</div>

I’ve tried my previous script, it works as expected, assuming you have properly defined the mesh `Th` of course.

---

<div class="post-metadata">

### Author: ![niaa](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@niaa](https://community.freefem.org/u/niaa)
#### Post date: [March 7, 2021, 6:36pm UTC](https://community.freefem.org/t/regions-permittivity/830/7 "2021-03-07T18:36:17Z")

</div>

Thanks for your quick response. I changed sth and it works now.  
The problem by defining as func erregion = (region == 1 ? er : ep); was that when I changed it to " func erregion = (region == 2 ? ep : er); " , the solotion became different. I guess it was just considering the first permittivity not other one.

---

<div class="post-metadata">

### Author: ![niaa](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@niaa](https://community.freefem.org/u/niaa)
#### Post date: [March 7, 2021, 6:51pm UTC](https://community.freefem.org/t/regions-permittivity/830/8 "2021-03-07T18:51:03Z")

</div>

May you tell me please what was wrong with difining as func ?

thanks alot.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [March 10, 2021, 3:46pm UTC](https://community.freefem.org/t/regions-permittivity/830/9 "2021-03-10T15:46:29Z")

</div>

remark, in this examples you can do is you have only 2 regions 1 and 2.

real[int] ee=[0.,1.,12.] ;  
func erregion = ee[region];
