For a LED package, the light emanated from the LED light source is actually refracted twice when transmitting from the inner and the outer surfaces of the lens. As shown in Figure 1, the inner surface refracts the incident ray \overrightarrow{\mathit{OA}} into first output ray \overrightarrow{\mathit{AB}}, which is the incident ray for the outer surface. The outer surface refracts the second incident ray \overrightarrow{\mathit{AB}} into second output ray \overrightarrow{\mathit{BR}}, which irradiates at the corresponding point R on the target plane. According to Snell's law, the rays \overrightarrow{\mathit{OA}}, \overrightarrow{\mathit{AB}}, \overrightarrow{\mathit{BR}} must satisfy the following equations.
{\mathit{n}}_{1}\frac{\overrightarrow{\mathit{OA}}}{\left\overrightarrow{\mathit{OA}}\right}\times \overrightarrow{{\mathit{N}}_{1}}={\mathit{n}}_{2}\frac{\overrightarrow{\mathit{AB}}}{\left\overrightarrow{\mathit{AB}}\right}\times \overrightarrow{{\mathit{N}}_{1}}
(1)
{\mathit{n}}_{2}\frac{\overrightarrow{\mathit{AB}}}{\left\overrightarrow{\mathit{AB}}\right}\times \overrightarrow{{\mathit{N}}_{2}}={\mathit{n}}_{3}\frac{\overrightarrow{\mathit{BR}}}{\left\overrightarrow{\mathit{BR}}\right}\times \overrightarrow{{\mathit{N}}_{2}}
(2)
where \overrightarrow{{\mathit{N}}_{1}} and \overrightarrow{{\mathit{N}}_{2}} are the normal vectors on the inner and outer surfaces, respectively. n_{
1
}, n_{
2
}, n_{
3
} are the refractive indices of each area, respectively. n_{
2
} is the refractive index of the lens material, and n_{
3
} equals 1.00 because the corresponding area is air. When the lens is primary lens, n_{
1
} is the refractive index of the silicone or phosphor silicone matrix; when the lens is secondary lens, n_{
1
} equals 1.00 because the area is air.
From Eqs. (1)(2), we may discover that these two equations can't be solved because the number of unknowns is more than the number of equations. But if we assume the inner surface as hemispherical surface, \overrightarrow{\mathit{OA}} and \overrightarrow{\mathit{AB}} are parallel and Eq. (1) can be neglected. This is the exact reason why most researchers simplify the problems by considering the inner surface as hemispherical. At the situation of this letter, we want to design the two surfaces simultaneously. We adopted the practical nonimaging optical design method to design the lens [12–16]. After the meshing of light source and target plane, we can obtain the vector of each incident ray (i.e. the edge angle θ_{
i
}) and the coordinates of corresponding points on the target plane. Then, we supposed that the inner and outer surfaces can be described by surface functions f_{
1
}(x,y,z) and f_{
2
}(x,y,z), respectively. The tangent plane at each point is the differential coefficient of the functions f_{
1
}(x,y,z) and f_{
2
}(x,y,z) at each point, and the unit normal vector is the orthogonal of the tangent plane at each point. To make the indefinite equations solvable, we can add appropriate extra conditions to balance the number of unknowns and equations. There may be a lot of extra conditions, which can help solve the problem, like surface functions relationship control, light deviation control, etc. Different extra conditions correspond to different applications. Two kinds of extra conditions are illustrated and discussed below.

1)
Surface function relationship control
As one kind of extra condition, we also can supply the relationship between the two surfaces. The relationship can be assigned based on appropriate assumptions. As the simplest cases, we can give the function of one surface and solve the other surface of the freeformsurface lens. For example, we can give the function of inner surface to calculate the function of the outer surface and vice versa.
As shown in Figure 2(a), when the function of the outer surface is given, i.e. f_{
2
}(x,y,z) is known, we firstly fix a point A_{
0
} as the vertex of the inner surface of the lens, and the normal vector at this point is vertical up. The second point A_{
1
} can be calculated by the intersection of the incident ray \overrightarrow{\mathit{O}{\mathit{A}}_{1}} and the tangent plane of the point A_{
0
}. Then applying Eq. (2), we can calculate the point B_{
1
} on the outer surface since the unit normal vector at point B_{
1
} is determined by the function f_{
2
}(x,y,z) and the corresponding point R_{
1
} is also determined previously. Then the unit normal vector at point A_{
1
} is also calculated by applying Eq. (1) and the tangent plane at point A_{
1
} is consequently determined. By repeating the this process until the edge angle θ_{
i
} equals 90°, we can get all the points and their unit normal vectors on the inner surface. As shown in Figure 2(b), when the function of the inner surface is given, i.e. f_{
1
}(x,y,z) is known, we can calculate the outer surface with the same method. After obtaining all the coordinates on the inner or outer surface, we fit these points to form the contour line of the lens's cross Section.

2)
Light deviation control
As another kind of extra condition, we can control the two light deviation angles on the two surfaces with proper ratio. For each ray, the total light deviation angle from the incident ray \overrightarrow{\mathit{OA}} to the output ray \overrightarrow{\mathit{BR}} can be obtained. With proper ratio, we can divide the total deviation angle as two components, corresponding to the two refractions on the inner and outer surfaces respectively. As shown in Figure 3, we firstly fixed point A_{
0
} and point B_{
0
} as the vertex of the inner and outer surface of the lens, respectively. The normal vectors at these two points were vertical up. The second point A_{
1
} on the inner surface could be calculated by the intersection of the incident ray \overrightarrow{\mathit{O}{\mathit{A}}_{1}} and the tangent plane of the point A_{
0
}. With proper deviation angles, we could obtain the ray \overrightarrow{{\mathit{A}}_{1}{\mathit{B}}_{1}} and ray \overrightarrow{{\mathit{B}}_{1}{\mathit{R}}_{1}}. The second point B_{
1
} on the outer surface could be calculated by the intersection of the ray \overrightarrow{{\mathit{A}}_{1}{\mathit{B}}_{1}} and the tangent plane of the point B_{
0
}. By applying Eqs. (1)(2), we could calculate the unit normal vectors and the tangent planes at point A_{
1
} and point B_{
1
}. And then we could obtain the third point A_{
2
} on the inner surface by the intersection of the incident ray \overrightarrow{\mathit{O}{\mathit{A}}_{2}} and the tangent plane of the point A_{
1
}. By repeating this process until the edge angle θ_{
i
} equaled 90°, we could get all the points and their unit normal vectors on the two surfaces. After obtaining all the coordinates on the inner and outer surfaces, we fit these points to form the contour line of the lens's cross section.
If the lens is designed as axissymmetrical lens, then we can get the freeform lens by rotating the contour line around the symmetry axis. If not, we can use the similar method to calculate the other contour lines. After obtaining all the contour lines, the lofting method can be used to form smooth surfaces of the lens between the contour lines [14].
What should be emphasized is that this general design method has many design DoFs. The extra conditions could be varied according to the different requirements and the resulting double freeformsurface lenses have different applications. Even for the two aforementioned extra conditions, it also has many design DoFs. As long as the optical performance, volume and profile of the designed lens are acceptable, the inner surface could be given as spherical, cubic, cylinder or even spheroidic and parabolic, while the outer surface is freeform, and vice versa. The ratio of the two deviation angle is also can be changed according to different applications. With other extra conditions, the method could be extended to design different double freeformsurface lenses.