A problem about subsection "Initial composition model,Function" in spherical shell

I just started to use ASPECT. Thank you very much for seeing this topic. I want to set the composition fields like this
1617955028(1)
No matter how I set the parmeter “phi”, it doesn’t work. I don’t know which parmeter lead to this wrong solutions. All paarmeters are attached in the end of this topic, my parmeters in subsection “Initial composition model” and output are as following:

#---------------Compositional fields model---------------#
subsection Compositional fields
  set Number of fields = 2
end

subsection Initial composition model
  set Model name = function

  subsection Function
    set Coordinate system   = spherical
    set Variable names      = r,theta,phi
    #set Function expression = if((r>1637000) && (phi<3.14159) && (phi>0), 1, 0) ; if((r>1400000) && (r<1537000) && (phi<1) && (phi>0), 1, 0)
    set Function expression = if((r>1637000 && phi<3.14), 1, 0) ; if((r>1400000 && r<1537000 && phi<1.55), 1, 0)
  end
end

Initial C_1 Fields:(No more pictures can be inserted, so I put it on Drawing bed)
C_1 output
Initial C_2 Fields:
C_2 output

Even if I replace the Initial composition model subsection “phi” by “theta”, it also don’t appear the initial composition as I wanted.
I really don’t know how to set the Initial composition model. I’d be grateful to you for answering my question.

Parmeter file:

#--------------------Global Parameters-------------------#

set Dimension                                  = 2
set End time                                   = 1.5e8
set Use years in output instead of seconds     = true
set Output directory                           = output-Luna01

#---------------Adiabatic conditions model---------------#

#--------------------Material model----------------------#
subsection Material model
  set Model name = composition reaction

  subsection Composition reaction model
    set Thermal expansion coefficient = 4e-5
    set Viscosity = 1e22
    set Composition viscosity prefactor 1              =0.1
    set Composition viscosity prefactor 2              =0.3
    set Density differential for compositional field 1 = 500
    set Density differential for compositional field 2 = 200
  end
end

#--------------------Initial model----------------------#
subsection Initial temperature model
  set Model name = spherical hexagonal perturbation
end

subsection Gravity model
  set Model name = radial constant
  subsection Radial constant
    set Magnitude = 1.89
  end
#set Model name = ascii data
#  subsection Ascii data model
#    set Data directory = ./gravity_data/
#    set Data file name = prem.txt
#  end
end

#----------Geometry model and Mesh refinement------------#
subsection Geometry model
    set Model name = spherical shell
    subsection Spherical shell
        set Inner radius  = 350000
        set Outer radius  = 1737000
        set Opening angle = 360
    end
end

subsection Mesh refinement
    set Initial global refinement          = 5
    set Initial adaptive refinement        = 4
    set Strategy                           = composition
    set Time steps between mesh refinement = 15
end

#--------------------Boundary Condition----------------------#
subsection Boundary velocity model
  set Zero velocity boundary indicators       = bottom
  set Tangential velocity boundary indicators = top
end


subsection Boundary temperature model
  set Fixed temperature boundary indicators = top, bottom
  set List of model names = spherical constant

  subsection Spherical constant
    set Inner temperature = 4273
    set Outer temperature = 973
  end
end
#---------------Compositional fields model---------------#
subsection Compositional fields
  set Number of fields = 2
end

subsection Initial composition model
  set Model name = function

  subsection Function
    set Coordinate system   = spherical
    set Variable names      = r,theta,phi
    #set Function expression = if((r>1637000) && (phi<3.14159) && (phi>0), 1, 0) ; if((r>1400000) && (r<1537000) && (phi<1) && (phi>0), 1, 0)
    set Function expression = if((r>1637000 && phi<3.14), 1, 0) ; if((r>1400000 && r<1537000 && phi<1.55), 1, 0)
  end
end

#---------------------Postprocess------------------------#
subsection Postprocess
  set List of postprocessors = visualization, temperature statistics, composition statistics
  subsection Visualization
    set Output format                 = vtu
    set Time between graphical output = 1.5e7
    set Number of grouped files       = 0
  end

  subsection Depth average
    set Time between graphical output = 1.5e7
  end
end

Dear Qyunian,

Is there a reason you need two compositional fields? In ASPECT, we typically define “background” properties, and then we use compositional fields to account for any deviations from the background. Your figure suggests that one compositional field would be sufficient.

If we let your “Composition 2” be the background field, the following prm subsections will yield Composition 1 in the sector pi/4 < theta < pi*3/4 (as shown in your diagram) and r > 1637000:

subsection Compositional fields
  set Number of fields = 1
end

subsection Initial composition model
  set Model name = function

  subsection Function
    set Coordinate system   = spherical
    set Variable names      = r,theta
    set Function expression = if((r>1637000 && theta<pi*3/4 && theta>pi*1/4), 1, 0)
  end

end

I hope that helps!

Best wishes,
Bob

P.S. You can name the spherical variables anything you like; it’s only the order of those variables that matters. For example, the following is identical to what I wrote in the last message:

  subsection Function

    set Coordinate system   = spherical
    set Variable names      = r,phi
    set Function expression = if((r>1637000 && phi<pi*3/4 && phi>pi*1/4), 1, 0)

  end

Dear Bob,

Thank you very much for your answer. I have just tried your advise, and I found my mistake is using number like “3.14” but not “pi” to express the angle. Your advise is really useful to me.
Thanks again for your kind help.

Shaohui Liu