First pass at merit function

This commit is contained in:
2022-10-10 11:46:27 +02:00
parent a80a7f749e
commit a61f15df44
5 changed files with 32 additions and 6 deletions

View File

@@ -1,8 +1,14 @@
module Main where
import Control.Lens
import Data.Either
import Petzval.Optics
import Petzval.Optics.RTM
import Petzval.System
import Petzval.Trace
import Petzval.Calculations
import Linear
import Numeric.AD.Mode (Scalar, Mode)
bk7 = SellemeierMat [ (1.03961212, 6.00069867e-3 )
, (0.231792344, 2.00179144e-2 )
@@ -34,6 +40,22 @@ system2 =
where s_sk16 = ConstMat 1.620408
s_f4 = ConstMat 1.616589
merit :: (Material mat, RealFloat a, Scalar a ~ Double, Epsilon a, Mode a) => [Element mat a] -> a
-- merit :: (Material mat) => [Element mat Double] -> Double
merit system = result
where baked = bake 0.587618 system
ep = entrancePupil baked
result = sum
. map (^2)
. map (\ angle -> rmsSize
. toListOf (each._pos._xy)
-- . (\x -> x :: [Ray a])
. rights
. map fst
. map (raytrace baked . createRay Nothing ep angle)
$ spiralPattern 100)
$ [0, 7.07, 15]
main :: IO ()
main =
let baked = bake 0.587618 system2