Mathieu Hemery
email: mathieu.hemery@polytechnique.org

Paul François
email: paulf@physics.mcgill.ca

Convergent evolution in silico of biochemical log-response

Numerous biological systems are known to harbour a form of logarithmic behaviour, from Weber's law to bacterial chemotaxis. Working on a logarithmic scale allows the organism to respond appropriately to large variations in a given input at a modest cost in terms of metabolism. Here we use a genetic algorithm to evolve biochemical networks displaying a direct logarithmic response. Interestingly, a quasi-perfect logresponse implemented by the same simple core network evolves in a convergent way across our different replications. The best network is able to fit a logarithm over 4 order of magnitude with an accuracy of the order of 1%. At the heart of this network, we show that a logarithmic approximation may be implemented with one single nonlinear interaction, that can be interpreted either as a phosphorylation or as a ligand induced multimerization and provide an analytical explanation of the effect. Biological log-response might thus be easier to implement than usually assumed.

Introduction

Multiple cellular pathways have evolved to work over several orders of magnitude. A spectacular example can be found in immune recognition, where cells can simultaneously be insensitive to tens of thousands of non cognate ligands while being sensitive to minute concentrations of agonists with only slightly higher affinity 1 . In this case, specialized mechanisms, implicating proofreading cascades and multiple biochemical feedbacks have been described 2 , implementing a so-called adaptive proofreading strategy 3,4 . Similarly, chemotactic response in E. Coli has been shown to be logarithmic, and there too, specific biochemical adaptation pathways are responsible 5 .

Log-normal distributed concentrations are also the norm rather than the exception in cellular biology [START_REF] Milo | Cell Biology by the Numbers[END_REF] and can be explained by a variety of simple mechanisms such as exponential decay or growth with a normally distributed rate or the accumulation of multiplicative noises [START_REF] Koch | [END_REF] . But if cells have to deal with enormous phenotypic variability, it seems reasonable to assume that they are routinely able to take logarithms of concentrations to filter it out. This is paradoxical since most of biochemical reactions rather work on a linear scale. Classical examples are Michealis-Menten/Hill (or more generally sigmoidal) kinetics, where rates quickly saturate above a well defined threshold 8 . This motivates a special study of general mechanisms underlying "logarithmic-response" over multiple orders of magnitude. As said above, previous works have already identified possible models and mechanisms to explain logarithmic sensing but to our knowledge few studies try to develop a direct biochemical computation of a logarithmic function. A general rule in such models is that one or several feedbacks are required to allow for logarithmic sensing. As an example, a synthetic biology approach combined positive feedback on low-copy-numberplasmid with a shunt component on high-copy-number-plasmid to provide sensitivity over 4 orders of magnitudes 9 . Another proposal relies on an allosteric system with sigmoidal responses, that modulates its saturation threshold with the help of a negative feedback to extend its range 10 . It is neither clear if such mechanisms are ubiquitous, nor if simpler mechanisms exist.

In this work, we turn to machine-learning based approach to design biochemical networks showing a response proportional to the logarithm of a given input. Such approaches have produced very good results to recover and predict models underlying physical or biological systems 11,[START_REF] François | Seminars in cell & developmental biology[END_REF] . A key advantage of those is their interpretability, circumventing the well known "black box" problem currently observed in machine learning [START_REF] Knight | There's a big problem with AI: even its creators can't explain how it works[END_REF] . We use ϕ-evo an evolutionary algorithm tailored for such biological problems [START_REF] Henry | [END_REF] . We find a simple and generic mechanism generating logarithmic response, where the Input concentration catalyzes a reaction where rates are polynomial in the substrate concentration. This allows for log sensitivity over several order of magnitudes. This could be easily implemented for instance with ligand induced multimerization/oligomerization of receptors 15 , a process that does not require any feedback. Positive feedforward and negative feedback interactions can then be added to improve the logarithmic behavior over 4 orders of magnitudes. Our work reveals that there might be simple mechanism without feedback underlying log-sensing in a generic way, which therefore might be more frequent than expected.

Theoretical Methods

We use the ϕ-evo software to evolve biochemical networks able to implement a logarithm [START_REF] Henry | [END_REF] .

In short ϕ-evo is a Python/C-based software simulating classical Darwinian evolution on a population of gene networks. Gene networks are encoded with the help of a pre-defined biochemical grammar. Possible interactions include protein protein interactions, transcriptional regulations, catalytic interactions (possibly with strong non-linear behaviours) and both passive and enzymatic degradations. All those interactions are included in the grammar for the simulations presented here. From a given gene network, ϕ-evo generates a set of ordinary differential equations that are numerically integrated to determine the behavior of this individual. Those simulated gene networks then go through a cycle of selection, growth and mutation, briefly detailed below. For an extended presentation of the biochemical grammar, modelization and algorithmic details, we refer the reader to the software description. [START_REF] Henry | [END_REF] ϕ-evo requires the definition of a fitness function for Darwinian selection. We use the simplest possible objective function to promote the evolution of logarithmic behaviour as depicted in figure 1. Each network contains an "Input" and an "Output" biochemical species.

Then, the concentration of the Input is fixed to a random constant value I (the distribution of which is exponential between 1 and 10 4 ) for an interval of duration τ and 0 otherwise (the distribution of τ is the sum of a constant and an exponential term making it both broad and never too short). ϕ-evo then integrates the differential equations corresponding to the biochemical network, and computes as an output O of the network the maximum of the concentration of the "Output" species as a function of time1 .

For each network, the corresponding set of ODE is then integrates N = 100 times with randomized choices for both I and τ and those data are collected to compute the network fitness:

ϕ = σ (α(I, τ )) α(I, τ ) 2 = α 2 (I, τ ) α(I, τ ) 2 -1, with: α(I, τ ) = O(I, τ ) log(I) . (1)
Here σ indicates the variance and . . . the mean. During our simulation, the average is taken over the N integrations with different random inputs. Intuitively, if the network takes a perfect logarithm then α(I, τ ) should be a constant independent of I and τ , so that each independent input choices should give the same constant α and the standard deviation defined in equation 1 should be 0. We thus aim to minimize σ. The division in the fitness definition is such that it does not impose a predefined value for the constant in front of the logarithm definition, thus any function of the form α log(I) will be selected. However, the higher the α the lower the noise and this creates an indirect selection for the highest possible constant which is the desired behaviour (see figure 1). σ can be interpreted as the quality of the logarithm taken as a linear function of log I (lower σ being higher quality).

Note that while the value of τ appears in the computation of O, it is not present in the evaluation of the fitness ϕ, hence the network should be able to get rid of the time for which the input is present and respond only to the very intensity of the input signal. Figure 1 visually illustrates examples of fitness computation.

ϕ-evo uses an elite strategy to implement the selection. At each generation of the algorithm, it selects half of the network population based on their value of ϕ. Some small random component is added to ϕ to ensure mixing of the networks populations. Once half of the networks are selected, we duplicate them and the duplicated networks go through a round of mutations. Mutations randomly add, remove or change biochemical interactions to the networks, based on the predefined biochemical grammar. In Supplement we give initialization files, fitness definition and mutation rates allowing to reproduce results presented here. For more details on ϕ-evo, check Ref. 14.

Results

Convergent evolution towards a simple biochemical implementation of the logarithm

A typical evolutionary simulation including a simulated evolutionary pathway (with value of ϕ as a function of the number of generations) and intermediate network structures is presented in Fig. 2.

The evolution reaches a fitness lower than 10 -2 in less than 150 generations and stabilize around 10 -3 . This means that for such network, the average relative deviation of the Output from the logarithm of the Input (up to a multiplicative constant) is less than 5%.

The simplest network topology achieving such a performance appears at generation 134, In D, the phosphorylated and unphosphorylated species form a complex, this interaction is an ad hoc form of repression that is very current in networks produced with ϕ-evo.

and is displayed in figure 2 C. Differential equations corresponding to this network are:

dS dt = k a I na I na + t a na -k p I S np S np + t p np + k d O -δ S S, (2)
dO dt = k p I S np S np + t p np -k d O -δ O O. (3)
This network work in the following way: the Input first activates the expression of a gene encoding a protein S (term I na I na +ta na ), then S is non-linearly catalyzed by I (term

I S np S np +tp np )
to produce the output, here in the example of a phosphorylation. Note that the input acts both as a transcriptional activator and a catalyst (kinase).

Improvement of the fitness over the course of the evolution corresponds to major changes in the topology or in the parameters of the system. For the example displayed on figure 2A Importantly, this particular network evolves because there is no restriction in ϕ-evo on the number/nature of reactions a species can be involved in. Here, the input acts both as a transcription factor and a kinase. This combination may not be possible in nature in some cases, but we checked that the logarithm function is preserved if we separate the kinase and transcriptional activities of the Input into an extra kinase activated transcriptionally by the Input (see Supplement for an explicit example).

Logarithm phenomenology and mechanism

A sketch of the best topology we obtained is displayed in Fig. 3 No simple analytic forms can be derived from the network equations, due to multiple nonlinearities. To proceed, we successively remove parts of the networks, and further optimize parameters using our fitness function to identify which interactions are most crucial at steady Figure 3: A. Convergent network structure evolved to produce a logarithmic response. Typically, the input activates or produces a species that should then be phophorylated to produce the output. To achieve an even better fitness, the evolved networks then may harbor a form or another of regulation (that is regulation, complexation or enzymatic degradation) of the output on its non-phophorylated form. B. Steady state concentration of the species A and B as a function of the input concentration (in log scale), the black line indicates the logarithmic function on which we fit our output concentration over the [10 0 , 10 4 ] range. Note the complex behavior of the precursor species the non-monoticity of which is crucial to perform the desired function. The mean error between the output and the desired logarithm is of the order of 1% on the range of interest. C. Same as B but for the case where both activation and regulation has been deleted. Note the weak range of variation of S and the deviation of O from the desired target. Still, the approximation of a logarithm is roughly correct, the mean error from the logarithm being of the order of 10%.

state.

As expected from the example of Figure 2, the negative regulation of species S by the Output is not crucial, and the network behaviour can be almost logarithmic without it.

Further removing the activation within the networks and optimizing parameters yields a behaviour that, without being logarithmic strictly speaking, still presents strong similarity with a logarithm upon 4 orders of magnitude as depicted in Figure 3 C. This behaviour can be analytically understood by considering the following limits of equations 2 and 3. On the one hand, at steady state for 3, assuming we are far from saturation for the catalytic interaction, we clearly have

O ∝ IS np (4)
On the other hand, substituting steady state equation 3 in 2 and assuming constant production, we have

δ S S + δ O O = k a ( 5
)
which is an effective conservation law stemming from the fact that S is transformed into O. and thus injecting this solution in equation 5:

Now let us remark that while

δ O O = k a -δ S O I 1 np (6) δ O O = k a -δ S exp 1 n p (log O -log I) (7) δ O O = k a -δ S - δ S n p log O + δ S n p log I (8) O = k a -δ S δ O + δ S δ O n p log I (9)
where we Taylor expand the exponential up to first order in 1 np and use the fact that log O is negligible in the last expression since, as we noticed, O is small by construction while I can take large values.

Equation 9 promises us a perfect logarithm (up to first order) if k a = δ S so that the first term in the r.h.s. cancel. Moreover we also see that increasing n p should be counterbalance by either lowering δ O or increasing δ S .

To verify this prediction, we numerically solve the equation 6 with the choice of coefficients described above and check that it effectively gives a logarithmic approximation when n p → +∞ as shown in supplement.

Parameter dependency and range constraints

While we have identified in the previous section the core mechanism for log-sensing, it is worth examining more carefully what range of parameters give consistent logarithmic behaviour.

To further clarify parameter dependency, we turn back to the full network displayed in Fig. 3 A, and study its behaviour when parameters are randomly chosen. For 5000 parameter sets, we compute the fitness ϕ and the range of output defined as the difference between the maximum and the minimum value of the Output when the Input varies from 1 to 10 4 and present the results in the Fig 4 . As we hope to find networks that harbour a low fitness but a high range, the better networks will be found in the bottom right corner (corresponding to maximum range, minimum fitness). The optimized network of Fig. 3 A is indicated with a red dot, and clearly displays parameter optimization with respect to networks with random parameters. Still it is interesting to see that random sets of parameters may reach interesting regions of the functional plane.

We define two subsets of interest. Blue dots identify a sub population of networks clustering on a bottom-right front. Parameter sets on this front achieve small values of the ratio between fitness and range. Small fitnesses lower than 10 -2 with ranges of order 1 are still parameters with an orange window of networks with both small fitness and high range, from our 5000, 260 networks reach this threshold thus indicating that 5.2 ± 0.6% of the parameter space produced an acceptable logarithmic approximation.

Figure 4: A. Fitness and range of response (defined as the difference between maximum and minimum Output values when the Input is varied) for 5000 random set of parameters (see details in Supplement for ranges of variation). Better networks are in the lower right corner. The red dot correspond to the optimized set of parameters for network of Fig. 3 A. We focus on two subsets of parameters. Blue dots are network close to minimal fitness over range ratio, corresponding to a linear front (∼ 870 parameter sets), The orange window are parameter sets that have both good fitness and range (∼ 260 parameter sets). B-C. Mutual information between parameters for the two parameter sets defined in Panel A. Warmer colours define stronger correlations, see the main text for the full detail of these correlations.

The second set being smaller is also more noisy.

We now consider those two subsets of parameters to determine how parameters are constrained. Distribution of each parameter inside a set does not reveal any particular pattern (see figure 10 in supplement), which steered us to look for second order correlation.

We compute the mutual information score for all couple of parameters for those two subsets, Fig 4 B-C (see Supplement for more details). High mutual information between two parameters means that their distributions are intertwined, thus indicating correlation between their values from set to set and revealing constraints on the biochemical interactions.

Most couples of parameters have low mutual information, indicating lack of any strong constraints between them. However, we identify three strong constraints for the network to perform well. The blue set presents two constraints. A first one is see on the activation rates:

k p + k a < 1 (Fig in Supplement)
, that constraints the sum of the production rate of S with the maximum catalytic rate. Indeed, if those rates are too high, the system will be blocked in the saturated regime and cannot take advantage on the non-linearity of the interactions, this is thus consistent with our analytical study above.

Another less intuitive constraint is observed on the phosphorylation parameters k p , n p see Fig. 5 : there is basically almost no selected set in the region above the first diagonal n p = k p (in rescaled units). To get a better understanding of the origin of this constraint, we took the network of Fig. 3 Thus to get a linear behaviour of S over the range of concentration considered, from a given set of optimized parameters, an increase of n p can be essentially compensated with an increase of k p . However it is also clear that increases of n p moves the curve more significantly than increases of k p , so that we expect there is a limit for which increases k p can no longer compensate n p , explaining why the region where n p is too big w.r. to k p is forbidden.

The orange set allow us to identify one last strong constraint: k a > d o asking that the degradation rate should be smaller than the production. This constraint is easy to understand as it ensures that the concentration of output may be high and thus allows for a large range in the output concentration.

Discussion

We have used in silico evolution (the ϕ-evo algorithm) to design a biochemical log-sensor.

Results of our simulations show that an almost perfect logarithmic sensor over 4 orders of magnitude can be obtained by combining feedback and feedforward interactions with a non linear interaction catalyzed by the Input.

The key log-sensitivity comes from Eq. More generally, assuming a relation such as Eq. 4 holds irrespective of specific biochemistry, we can expect O and S to vary logarithmically with I as long as both O and S are constrained to vary on a predefined range. Here, the latter constraint stems from the effective conservation law in equation 5, which imposes limits on both concentrations at the same time. An alternative way to perform this would simply be that neither S and O are degraded, nor S is produced, so that Eq. 4 would directly be mass conservation. We have also identified parameter dependencies for this system to work correctly, key of which is the necessity to play on the non linearity of the hill functions, that is avoid both high and low saturation regimes. The constraint that n p should be small enough with respect to k p also suggests that the non-linearity should not be too high. This is of biological relevance in a case where n p is the number of receptors forming multimers, which thus should stay relatively low.

One can also refine the system to get a "perfect" log, by addition of other feedbacks that are found by ϕ-evo. Of course, it is not entirely clear why a cell would need to take an exact log, versus a response that would only be log-like. In our case, extra feedbacks can rather be thought of as post-processing of a core signal sensitive over orders of magnitudes, and as such can be likely performed otherwise downstream of the Output. This vision is very different from previous proposals, where feedback need to be carefully engineered to ensure log sensitivity 9,10 . While it is not clear which solution is more amenable to be found by biological evolutionary tinkering, solutions presented here are de facto evolvable, within the range of allowed biochemical interactions and mutations in our simulations. The dual fact that we observe very strong convergent evolution towards this solution and that receptor multimerization is a possible common mechanism to implement it suggests that the solution we propose might be easier to find by evolution, and therefore potentially ubiquitous.

Figure 1 :

 1 Figure 1: To compute the fitness, each network is evaluated under different randomized inputs (panel A), and the results are then gathered in a single score (panels BCD). A. Sketch of an input (in blue) and the response of the network in orange, the input parameters (τ and I max ) are drawn from two distributions and the response is computed numerically through integration of the ODE corresponding to the network. We then retrieve I max and O max to compute the fitness score ϕ. B-C-D. Sketches of the fitness computation, blue dots represent the responses for different input on the I max , O max plane. The red line gives the ideal linear response and the inset represent the rescaled distribution the standard deviation of which we have defined as our fitness score. (note that the scale are the same for every plot). The final score of this three cases is: ϕ B = 3.10 -2 , ϕ C = 6.10 -3 and ϕ D = 7.10 -2 .Note that this definition also naturally favors large response range as a high mean will flatten the noise and lower the variance as seen on panel C.

Figure 2 :

 2 Figure 2: A. Excerpt of the fitness as a function of time (in generation). Vertical red lines correspond to changes of network topologies while green lines correspond to changes of major parameters. Orange stars correspond to the networks of panels B-C-D. See main text for details. B -D. Representation of the best network in the current population after generations 100 (B), 150 (C) and 200(D). Boxed coloured letters correspond to biochemical species, Input is the red triangle S 0 , Output is the Species S 2 . Arrows indicate possible biochemical interactions. In B, only a phosphorylation is present (red arrow), in C the input activates the transcription of the first species (green arrow).In D, the phosphorylated and unphosphorylated species form a complex, this interaction is an ad hoc form of repression that is very current in networks produced with ϕ-evo.

  figure 2 C is now present. Generations 134 and 144 (c and d) correspond to increase in production rate of S and in catalytic rate by the Input, which allows for subsequent major improvement of the fitness, plateauing at fitness 10 -2 . At generations 162 and 200 (e and f), changes in network topologies allow for small improvement of the fitness. For instance, at generation 200 a protein-protein interaction appears between S and O, allowing for an effective repression of S by O that slightly improves the fitness.The motif displayed in figure2C, that allow the simulation to reach low fitness region, appears repeatedly in our simulations. For instance, in a typical run of 20 consecutive simulations with exact same mutation parameters, 10 ended with a sufficient fitness to be considered as successful (of the order of 10 -2 or lower ). Surprisingly, each of these simulations display the same core topology at the heart of the network of interactions corresponding to Fig2 C. Thus our simulations display strong convergent evolution. Variations on the numerical value of the parameters, other species and interactions around the functional core can be observed but do not impinge the main function of the core network. Interestingly,

  Fig. 3 details the behaviour of the two species composing the network as a function of the Input, compared to a logarithmic behaviour. We clearly see that such a simple network can implement a precise logarithm of the Input over 4 orders of magnitude, compatible with what is typically observed in processes such as immune recognition. Furthermore, this logarithmic behavior works at steady state values of both S and O, keeping I constant. However it is far from clear how such behaviour emerges from the interactions, requiring a more detailed analysis to disentangle the influence of various biochemical interactions.

  I varies over 4 order of magnitudes, S and O vary only on a limited range due to their logarithmic nature. From equation 4 we can write S = O I 1 np

  C, ran several simulations with increasing values of n p , and k p , and study the behaviour of S. Increases of n p clearly moves the behaviour of S towards the right, with saturation appearing for small Input concentration. Conversely, increases of k p moves the behaviour of S towards the left with less saturation for small Input concentration.

Figure 5 :

 5 Figure 5: A. Relation between k p and n p for the network in the blue (A) and orange (A') set. The constraint is manifest although subtle. B. Influence of n p on the solution of the network 3C, the hill coefficient of the phosphorylation thus allow to have a more and more linear response but shift the linear part on the high input regime. C. Influence of k p on the solution of the network 3C, the rate of the phosphorylation thus correspond to a shift on the low input that allow to compensate for the shift due to the hill coefficient. Note however that this shift seems logarithmic in k p (similar shift for our 4 curves that have a log spacing).

  6 relating I and O. It is clear here that such nonlinear catalysis could arguably constitute one of the simplest (if not the simplest) mechanism implementing a logarithmic response. Such process is not unrealistic. A first possibility is to have multiple phosphorylations as suggested in REF. Another easy way to get high powers in Eq. 4 is to assume that biochemical species S have to form multimers before being catalyzed in the active form O by I. Some Input can then trigger internalization of receptors and subsequent signalling, effectively implementing log-sensing. Such processes are common in biology. For instance in G protein-coupled receptors signalling, agonist triggers oligomerizations of receptors15 . Another context is immunology where cellular receptors are well-known to form multimers at the surface of the cell16 and are phosphorylated to trigger response 17 . Such networks (with internal feedback) could thus work directly in the log range for Input concentration, ensuring broader response or non-trivial scaling laws18 .

those choices can be relaxed, for instance results were similar when the "output" was the integral of the output concentration or its final concentration instead of it maximum. This property is actually a direct consequence of our desired independance of the final output in the time of the output τ as discussed later.

The precise form of this control is suject to variability between the different simulations, it may be a transcriptional regulation, a protein protein interaction that form a dimer with low dissociation or high degradation or a direct enzymatic degradation, in all these cases however, the negative influence is manifest.

Supporting Information Description

• A short document gathering figures, details and explanations not important enough to be embedded in the main text and refer in it as supplement.

• Initialization files of the main run described in the text (to be used with ϕ-evo software).

Note also that all our source code files for the optimization or simulation are written in Python and may be obtained through mailing the authors.


K Krupa

F Baronio

M Conforti

S Trillo

A Tonello

V Couderc

Zero focusing via competing nonlinearities in BBO crystals

We investigate nonlinear focusing behavior of light beams propagating in beta-barium-borate (BBO) crystals under mismatched second-harmonic generation. We clearly identify experimentally multiple self-focusing and defocusing regions against the orientation angle, and the condition where competing quadratic and cubic nonlinearities perfectly compensate each other (zero-focusing point).

Introduction. Quadratic optical media are usually exploited for frequency conversion applications. However, the energy conversion process is always accompanied by nonlinear phase shifts of the interacting fields, as recognized long ago [1,2]. This concept remained nearly dormant until the beginning of the nineties when phase shifts produced in quadratic processes attracted a new surge of interest [3][4][5][6], also related to their exploitation for controlling optical signals in the spatial, temporal and spectral domains [7][8][9][10][11][12][13][14][15][16][17].

Any three-photon mixing process entail nonlinear phase shifts of all fields which, in the CW limit, are generally described by complicated periodic behavior with distance. However, in the regime of large phasemismatches, the phase shifts follow a Kerr-like behavior, being nearly proportional to distance and intensity [5]. This regime is also referred to as cascading limit [7] to recall the fact that the phase shifts accumulate through many repeated up-and down-conversion processes. Remarkably, such phase shift can be either self-induced [5] or cross-induced [6], while its sign depends on the sign of mismatch, and can be opposite for the different frequency components [10], thereby adding great flexibility in the applications.

Mostly exploited for its simplicity is the nonlinear phase shift of the fundamental frequency (FF) field occurring via second harmonic generation (SHG) with no seed at second-harmonic (SH). In this configuration the cascaded phase shifts can be controlled through the wavevector mismatch by simply adjusting the orientation or the temperature of the crystal. Particularly interesting is the ability to generate negative phaseshifts which allows to access intriguing regimes (e.g. soliton propagation in normally dispersive bulk media and strong pulse compression and shaping without catastrophic collapse [8,17]), underlining the most innovative new possibilities [18][19][20].

However, in general, the net phase shift impressed on a light beam also contain a natural contribution from the cubic (Kerr) nonlinear index n existing in any material and usually positive. Therefore, one might think about cascaded χ (2) and χ (3) processes as contributing to an overall effective nonlinear index as [11,21]. Since the cubic index contribution n

n 2 = n (2) 2 + n (3) 2
(3) 2 has negligible dependence on crystal orientation and temperature, it acts as a bias to the total nonlinear index. As a result, multiple self-focusing and self-defocusing regions can exist. For the typical case, when cubic phase shifts are positive, self-defocusing is expected to be possible within a finite range of mismatches (crystal orientations) on one side of phase-matching condition.

The aim of this Letter is to determine theoretically and experimentally such range for beta-bariumborate (BBO) crystals. In particular, by observing the self-focusing and defocusing behavior of standard laser beams in BBO, we are able to clearly show the existence of a critical angle where the quadratic and cubic contributions mutually compensate for a wide range of input beam intensities, remarkably leading to a zero-focusing condition. To the best of our knowledge, compensation of this kind was achieved previously only by employing different crystals in back to back configuration [11]. Our experimental results agree well with theoretical analysis based on the cascading reduction of SHG equations, taking into account the Kerr coefficient of BBO.

Competing nonlinearities in BBO. We consider the propagation of an intense ordinarily polarized beam E 1 at FF ω = ω 0 , together with its SH (ω = 2ω 0 ), extraordinarily polarized beam E 2 , generated through a type-I configuration. Since temporal effects over the time scale of the experiment are negligible, the following nonlinear coupled equations can be safely employed to describe SHG in this configuration [21][22][23]

i ∂E 1 ∂z + 1 2k 1 ∇ 2 ⊥ E 1 + χ 2 E * 1 E 2 e i∆kz (1)
+ χ 31 |E 1 | 2 + χ 32 |E 2 | 2 E 1 = 0, i ∂E 2 ∂z + 1 2k 2 ∇ 2 ⊥ E 2 + χ 2 E 2 1 e -i∆kz (2)
+ χ 33 |E 1 | 2 + χ 34 |E 2 | 2 E 2 = 0,
where

E 1,2 = E 1,2 (x, y, z), ∇ 2 ⊥ = ∂ 2 /∂x 2 + ∂ 2 /∂y 2 , χ 2
and χ 3k are proportional to the relevant elements of the quadratic and cubic susceptibility tensors, respectively (χ 2 refers to ooe three wave interaction, χ 31 to oooo, χ 32 to eeoo, χ 33 to ooee, and χ 34 to eeee four wave mixing interactions); z is the propagation distance;

∆k = k 2 -2k 1 = 2[n e (2ω 0 ; θ) -n o (ω 0 )
]ω/c is the wavenumber mismatch, n o (ω 0 ) and n e (2ω 0 ; θ) being the ordinary and extraordinary refractive index at FF and SH, while θ is the angle of the propagation direction with respect to the optical axis of the crystal.

In Tables 1 and2, we report the effective nonlinearities for the crystals of class 3m to which BBO belongs, as a function of rotation angles (θ, φ) by specifying the relative type of interaction. For instance, ooe (o + o → e) indicates the upconversion of two ordinarily polarized photons that generate an extraordinarily polarized photon at SH (for further details see Refs. [24,25]).

Coefficient Expression

Interaction

d 0 = -
m 2 /V 2 , c 10 = -0.24 • 10 -22 m 2 /V 2 , c 16 = -1.4 • 10 -22 m 2 /V 2 [24].
In the cascading regime (high |∆k|), the leading order equation that can be derived from Eqs. ( 1) is the following nonlinear Schrödinger equation that governs the evolution the ordinary FF beam E 1 [21,26]:

i ∂E 1 ∂z + 1 2k 1 ∇ 2 ⊥ E 1 + (γ 2 + γ 3 ) |E 1 | 2 E 1 = 0 , (3)
where cascaded quadratic and cubic Kerr nonlinearities are expressed as γ 2 = -(

ω0d ef f n0c ) 2 1 ∆k [m/V 2 ] and γ 3 = 3 8 ω0 c ef f n0c [m/V 2 ]
, where d ef f = d 1 and c ef f = c 4 are the effective nonlinear coefficients from Tables 1,2.

Figure 1 shows the effective nonlinear index γ = γ 2 + γ 3 , resulting from cascading-quadratic γ 2 , and cubic γ 3 contributions, as function of the angle θ, at fixed φ = 90 o . Multiple self-focusing and defocusing regions can be identified. In particular, in the region of positive mismatches (γ 2 < 0), a zero-focusing point is identified at θ c = 18.4 o , where the quadratic and cubic contributions exactly balance (γ 2 = -γ 3 ). While for angles θ < θ c the mismatch increases and hence the Kerr effect prevails leading to self-focusing, for increasing angles θ > θ c the mismatch decreases and leads cascading to dominate thus resulting into self-defocusing, until for θ approaching the phase-matching angle θ = 22.9 o , the cascading picture breaks down due to increased efficiency of SHG (shaded region in Fig. 1). For angles greater than the perfect phase-matching angle, γ 2 and γ 3 have the same sign, leading to enhanced focusing. Experimental results. A sketch of our experimental setup is reported in Fig. 2. We employ a sample of BBO crystal with a square aperture of 6 × 6 mm and a length of 20 mm. The crystal is cut for frequency doubling at 1064nm under type-I (ooe) phase-matching, at the angles θ = 22.9 o and φ = 90 o to the principal axes. The crystal faces are coated for antireflection at 1064 nm. The crystal is pumped using a Q-switched, mode-locked Nd:YAG laser which delivers 30 ps pulses at 1064 nm at a repetition rate of 20 Hz, with energy up to 1.23 mJ.

A polarizer in between half-wave plates are used to adjust the energy and the polarization of the pump pulses. The pump light is collimated using a lens of 140 mm focal length. The average beam diameter at the input is around 140µm FWHM. The spatial beam patterns at the output of the crystal are imaged, with magnification G = 4.6, onto a CCD camera and analyzed. Under such experimental conditions, we characterize the spatial dynamics of an ordinary FF beam E 1 at the output of the BBO crystal, at different crystal orientation angles and input energies.

In Fig. 3 we summarize the dependence of the beam diameter (FWHM) at the output of the BBO crystal versus crystal orientation angle θ, for different input energies. First notice that diffraction has by itself negligible impact due to the large beam size (see curve relative to the linear limit in Fig. 3), while it becomes obviously effective, in the nonlinear regime, to transform the selfinduced spatial phase modulation into beam narrowing (self-focusing) or broadening (self-defocusing). The data indicate, as expected from theory, the existence of different nonlinear focusing and defocusing regions. In particular in the region of negative phase mismatches (θ > 24 o in Fig. 3), the cascading effect always adds up to the Kerr coefficient leading to self-focusing (beam narrowing). Conversely for positive mismatches we observe opposite behavior across the critical angle θ c = 18.6 o , at which the beam travels nearly undistorted due to mutual balance of Kerr and cascading nonlinear index. While for θ < 18.6 o , the FF beam self-focuses due to dominant positive Kerr index, for 18.6 o < θ < 22.5 o the cascading nonlinear index overwhelms the Kerr effect causing the beam to defocus. Remarkably, while increasing the input energy (intensity) results into an enhanced nonlinear effect, the point of zero-focusing remains the same with good accuracy regardless of the beam intensity. In order to show that the beams undergo self-focusing or defocusing without substantial distortion, we also display in Fig. 4 the beam profiles obtained for fixed input energy (0.54 mJ) for three characteristic values of the angle θ across the critical value θ c (vertical lines in Fig. 3). In particular the defocusing behavior in Fig. 4(a,d), obtained for θ = 22 o above the critical value θ c , is contrasted with the focusing behavior in Fig. 4(c,f), obtained below the critical value θ = 14.7 o < θ c , while Fig. 4(b,e) corresponds to the critical angle that give rise to the undistorted propagation. Conclusions. We have considered the effect of nonlinear phase shifts impressed on light beams during propagation in BBO crystals, showing evidence for competing quadratic and cubic contributions. We have identified theoretically and have demonstrated experimentally the existence of multiple overall self-focusing and defocusing regions, and the existence for a critical value of orientation which yields a compensation of cascading and cubic contributions.

2 γFig. 1 .

 21 Fig. 1. (Color online) Total effective cubic nonlinearity γ, resulting from both quadratic γ 2 and cubic γ 3 contributions, plotted versus the angle θ. The shaded domain identifies the region where cascading breaks down and SHG enters the regime of efficient conversion.

Fig. 2 .

 2 Fig. 2. (Color online) Experimental setup. Nd:YAG laser pump delivering 30 ps pulses, at 1064 nm, 20 Hz repetition rate; L lenses; λ/2 half wave plates; P polarizer; quadratic uniaxial BBO crystal; CCD camera.

Fig. 3 .

 3 Fig. 3. (Color online) Beam diameter (FWHM of intensity) at FF measured at BBO crystal output vs. crystal rotation angle θ, for different energy of the pulse: linear regime (dotted line); 0.08 mJ (blue squares); 0.34 mJ (gold circles); 0.54 mJ (magenta circles); 1.23 mJ (green diamonds).

Fig. 4 .

 4 Fig. 4. (Color online) (a-c) measured 2D output beam shapes and (d-f) corresponding beam profiles vs. y (x = 0 section), compared with the input. (a,d) θ = 22 o ; (b,e) θ = θ c = 18.6 o ; (c,f) θ = 14.7 o . Here the input energy is 0.54 mJ.

Table 1 .

 1 3d 31 cos 2 θ sin θ -d 22 cos 3 θ sin 3φ eee d 1 = -d 22 cos 3φ cos 2 θ eeo, oeo, oee d 2 = -d 31 sin θ + d 22 cos θ sin 3φ ooe, eoo, oeo d 3 = d 22 cos 3φ ooo Effective quadratic nonlinear coefficients. d 22 = 2.2pm/V, d 31 = -0.04pm/V. = c 11 cos 4 θ + c 33 sin 4 θ + 3 2 c 16 sin 2 2θ eeee -4c 10 sin 3φ sin θ cos 3 θ c 1 = 3 2 c 10 cos 3φ sin 2θ cos θ eeoe, eeeo c 2 = -1 3 c 11 cos 2 θ + c 16 sin 2 θ ooee,eeoo +c 10 sin 2θ sin 3φ c 3 = c 10 cos 3φ sin θ oooe, ooeo c 4 = c 11 oooo

	Coefficient Expression	Interaction
	c 0

Table 2 .

 2 Effective cubic nonlinear coefficients. c 11 = 5.6 • 10 -22

Acknowledgments F.B., M.C. and S.T. acknowledge funding by the Italian Ministry of University and Research (MIUR), under grant PRIN 2009P 3K72Z. K.K., A.T. and V.C. acknowledge the financial support provided by OSEO within the frame of the project VERTI-CAL.


David Janin
email: janin@labri.fr

A Timed IO monad

Programming with explicit timing information is often tedious and error prone. This is especially visible in music programming where, when played, the specified durations of notes and rests must be shortened in order to compensate the actual duration of all surrounding processing. In this paper, we develop the notion of timed extension of a monad that aims at relieving programmers from such a burden. We show how, under simple conditions, such extensions can be built, and how useful features of monad programming such as asynchronous concurrency with promises or data-flow programming with monadic streams can be uniformly lifted to the resulting timed programming framework. Even though presented and developed in the abstract, the notion of timed extension of a monad is nevertheless illustrated by two concrete instances: a default timed IO monad where programmers specify durations in microseconds, and a musically timed IO monad, where programmers specify durations in number of beats, the underlying tempo, that is, the speed of the music in beats per minute, possibly changed whenever needed.

Introduction

Timed programming. The simplest example of timed programming is probably a program that plays some music. Assume a function f :: Int → Note that tells which note is to be played at any instant n from start. Assume that we want to play each of these notes for one second, with one second of silence (or rest) between each note. With duration arguments expressed in seconds, in Haskell's IO monad, one could expect that the program: playMusic :: (Int → Notes) → Int → IO () playMusic f n = do {playNote (f n) 1; delay 1; playMusic f (n + 1)} realizes such an expected behavior when launched by playMusic f 0. While this program should be correct, for it is defined with the correct timing specification, it is actually not, for it relies on the false assumption that every other computations but those that are specified with a given duration are instantaneous.

More precisely, one can define the time drift of this program as the difference between the actual instant a note is played and the specified instant it should have been played. Then one can observe that, when ran, the time drift of the program above is unbounded. Indeed, it increases, note after note, at least by the actual duration of the computation of each note. In other words, such a program, when run in the IO Monad yields a time leak. Playing correctly such a music requires at least reducing the specified duration of each note or rest by the actual duration of the surrounding computations, implicitly but wrongly assumed to be of neglectable duration, not mentioning the time inaccuracy of actions such as delays.

Though simple, the explicit programming of such reductions in order to achieve a correct scheduling in time is repetitive, tedious and therefore error prone. We aim at relieving programmers from such a burden. One way to achieve this is to treat the program above as correct, for it specifies correct specified durations, and, instead, to change the way it is executed at runtime, that is, to change the underlying monad.

A timed IO monad. It is a well established fact that, thanks to monad modeling, pure functional programming can be safely extended to programming with side effects [START_REF] Wadler | Comprehending monads[END_REF][START_REF] Moggi | A modular approach to denotational semantics[END_REF]. Observing that passing time is a side effect, we thus aim at designing some timed monad that freely allows the programmer to assume that many actions are instantaneous, even if they certainly are not, and assume that all other actions have a specified positive duration, even if their actual durations will be shortened for achieving a correct scheduling.

This can be done by extending monads to timed monads in such a way that there is a clean distinction between:

(1) the specified temporal scheduling, automatically derived from the specified durations of the timed actions contained in a program, (2) the actual temporal scheduling observed when running that program in the underlying monad, induced by the actual durations of these timed actions, in such a way that, if possible and within reasonable bound, the actual temporal scheduling matches the specified temporal scheduling.

Observe that such a distinction between specified and actual temporal scheduling is fairly standard in music. The specified scheduling is described in the music score, as written by the composer, the actual scheduling is observed during the music performance, as defined by the musicians.

Organization of the paper. The notion of timed extension of a monad is defined in Section 2 via a type class and some equational properties every instance of that class shall satisfy. We also discuss the validity of these equations, fairly sensitive in presence of measured time.

In Section 3, we show how a monad can be uniformly extended into a timed monad as soon as it is equipped with basic timing primitives. This is achieved by extending the (implicit) monad state by an (explicit) timestamp that refers to the expected or specified timestamp in that state. Under simple conditions of the existing basic timing primitives, the time drift is provably positive in any state. Applied to the IO monad, this yields a timed IO monad with duration measured in microseconds.

Considering multi-scales approach, we provide in Section 4 another uniform timed extension of a monad, with basic timing primitives defined over one du-ration type, that yields a timed monad extension defined over another duration type. Applied to the IO monad, this yields a musically timed IO monad with duration measured in number of beats, a dynamically changeable tempo defining the beat rate w.r.t. to the underlying physical duration type.

Last, we show how various monadic programming features, when available in the underlying monads, can be lifted to their timed extensions. This includes asynchronous concurrent programming with promises (Section 5), or data-flow programming with monadic streams (Section 6). Related works are then discussed in Section 7 before examining some potential followups in Section 8.

Timed monad class

We describe below the notion of timed extension of a monad. The monads we shall consider are assumed to be strict, that is, when executing a bind m > > = f , the action m is always evaluated before evaluating f on the returned value, i.e. the bind is strict in its first argument.

Timestamp, duration, time scale and time drift

We briefly review here (our encoding of) basic timed concepts. A timestamp is defined here as the duration elapsed from some fixed but unknown initial time. We expect timestamps, therefore durations as well, to be totally ordered in a time scale. In Haskell, this is done by putting:

newtype Time d = Time d deriving (Eq, Ord ) where d is the duration type and Time d is the timestamp type. While the sum of two durations makes perfect sense, the sum of two timestamps does not, so we (only) equip timescales with the following primitives:

duration :: Num d ⇒ Time d → Time d → d duration (Time d 1 ) (Time d 2 ) = (d 1 -d 2 ) shift :: Num d ⇒ Time d → d → Time d shift (Time d 1 ) d 2 = Time (d 1 + d 2 )
that measures the (relative) duration between two timestamps, and that shifts a timestamp by some duration.

As already mentioned in the introduction, a key point of our proposal lays in the distinction between:

(1) expected timestamps used for scheduling specification, (2) actual timestamps observed along scheduling realization. This distinction induces a timing performance measure: the time drift defined as the difference between the actual timestamp and the expected timestamp.

It is a desirable property that, in a running timed program, the time drift is kept positive so that no action is actually scheduled before its specified time, and bounded so that any specified duration above that bound can accurately be handled by the underlying scheduler.

Timed monad

Simply said, a timed monad is a monad where every action has some specified (possibly dynamic) duration. The interface of a timed monad is detailed by the following type class: The meaning of these primitives is detailed below. Let us mention however that now shall return the current specified timestamp, drift shall return the current time drift, the actual or real timestamp being defined by the following derived action:

class (Ord d ,
realNow :: TimedMonad m d t ⇒ t (Time d ) realNow = do {t ← now ; d ← drift; return (shift t d )}
insisting again, if ever needed, on such a crucial distinction we are making between specified and actual timing information.

We provide below some equational laws that every timed monad instance shall satisfy. For such laws to be stated smoothly enough, we define the following timed monad action that, parameterized by a timed action m, returns its specified duration, that shall always be positive. dur :: TimedMonad m d t ⇒ t a → t d dur m = do {t 0 ← now ; ← m; t 1 ← now ; return (duration t 1 t 0 )} Observe that computing such a specified duration implies running the action together with its side-effects but dropping its returned value. This means that, in practice, it shall be of little use. We will later see, in Section 5, another way to retrieve the specified duration of a running timed action for using it elsewhere in a program.

Timed monad laws

The semantics of timed primitives is detailed more formally by the following invariant laws that shall be satisfied by any monad m extended into a timed monad t over a duration type d . The reader shall keep in mind that dur measures specified durations, not real ones, most of the laws being obviously false when precise enough real durations are considered.

Monad primitives. First, since the timed monad t is first a monad, the usual monad laws shall be satisfied:

return a > > = f ≡ f a (1) m > > = return ≡ m (2)
(m > > = f ) > > = g ≡ m > > = (λx → f x > > = g) (3)
with the following duration laws for monad primitives:

dur (return a) ≡ return 0 (4)

dur (m > > m ) ≡ dur m > > = λd → dur m > > = λd → return (d + d ) (5)
for every value a :: a, action m :: t a, action m :: t b and function f :: a → t b.

In other words, return actions take no time and the duration of two actions composed by the bind operator is the sum of the durations of these actions. As a derived law, since fmap f m = m > > = (return • f ), we also have:

dur m ≡ dur (fmap f m) (6)
for every action m ::t a and function f ::a → b. In other words, in a timed setting, functors preserve specified durations, time measurement acting over types as a fibration [START_REF] Janin | Spatio-temporal domains: an overview[END_REF].

Current (specified) time and drift. The action now shall instantaneously return the current specified timestamp as evaluated by accumulating the specified durations of the action performed before that one. The action drift shall instantaneously return the current time drift, that is, the difference between the actual timestamp (as measured by the underlying runtime) and the specified timestamp (as stored in the underlying timed monad state). By instantaneous, we mean that the following equations shall be satisfied:

dur (now ) ≡ return 0 (7) dur (drift) ≡ return 0 (8)
These equations also imply that neither now nor drift have any side effect.

Delays. The action delay d shall wait until the current specified timestamp (as returned by now ) shifted by the given positive duration d is eventually passed for real therefore, in optimal cases, reducing the time drift to a minimal value.

The following laws shall be satisfied:

dur (delay d ) ≡ delay d > > return d (9
)

delay (d 1 + d 2 ) ≡ delay d 1 > > delay d 2 (10) delay (-d ) ≡ return () (11)
for every positive duration d d 1 d 2 :: d . The first law states that the specified duration of delay d is the parameter d, the second one states that delay restricted to positive durations is additive with respect to bind, the third one states that delays with negative durations have no effects at all. As we shall observe in 5.3, as safer assumption could be that a delay of negative duration creates a temporal causality error.

Instantaneous lift. The function lift shall turn an action of the underlying monad m to an action in the timed monad t with the following laws that shall be satisfied:

lift • return ≡ return (12) lift (m > > = f ) ≡ lift m > > = (lift • f ) (13) dur (lift (m)) ≡ lift m > > return 0 ( 14
)
for any m :: m a and f :: a → m b. The first two laws are the usual laws for monad transformers. Any instance (TimedMonad m d t) is a transformation of the monad m into the monad t. However, we have not specified here a monad transformer since only specific monads, equipped with some timing primitives, can be transformed this way. The third law states that, by definition, the specified duration of the timed action lift m :: t a with m :: m a is zero, regardless of the actual duration of the action m.

In practice, this assumption means that lift shall only be used on actions that are reasonably instantaneous, e.g. printChar c in the IO monad, but should not be used on actions that are visibly not instantaneous, e.g. getChar in the IO monad as this would immediately yield an unbounded time drift. As we shall see below a timed lift function is available for that latter case.

Runs. The function run allows for moving a timed action back into the underlying untimed monad with:

run • lift ≡ id (15)
i.e. lift preserves the essence of the actions it lifts. Observe that over timed actions, the reverse direction does not hold since we have

lift (run m) ≡ m (16)
as soon as the timed action m has a non-zero duration.

Timed lift. Deriving from these primitives, we can lift any monad action from the underlying monad to the timed monad taking into account its actual duration1 by: timedLift :: TimedMonad m d t ⇒ m a → t a timedLift m = do {a ← lift m; d ← drift; delay d ; return a } Such a timed lifting is then applicable to visibly non-instantaneous such as blocking actions, e.g. getChar in the IO monad.

On the validity of timed monad extensions

One may wonder if there exists any timed extension of a monad at all that fulfills the properties stated above. Strictly speaking, with unrestricted usage of drift combined with an accurate measurement of physical time, the answer is no ! Indeed, given two distinct but equivalent timed actions m 1 and m 2 , we have:

m 1 > > drift ≡ m 2 > > drift (17)
unless m 1 and m 2 have the same actual duration, which is very unlikely. This suggests that, unless measuring time drift for testing purposes, the function drift shall not be used. However, such a suggestion is not applicable for, as seen above, the function timedLift, necessarily defined with drift, is needed for lifting monad action with unbounded real duration. In other words, when extending an untimed monad into a timed one, there necessarily are functions such as timedLift that do not preserve (untimed) monad action equivalence. This implies that the validity of all timed equations but (15) shall only be observed in a timed setting. In some sense, timed and untimed worlds shall be kept distinct and incomparable, each of them being equipped with its own induced action equivalence.

Default timed monad instances

We provide below a default instance of a timed extension of a monad that can be defined as soon as that monad admits enough primitives for time handling. where getRealTime shall return the real timestamp measured over the duration type d , waitUntil shall wait until the specified time stamps is passed (for real), and the derived action getDrift shall therefore compute the difference between the real current timestamp and the one passed in parameter. Any monad with timing information shall satisfy the following properties:

(1) Time monotonicity: for every action m :: m a, the action

getRealTime > > = λt 1 → m > > getRealTime > > = λt 2 → return (t 0 , t 1 ) shall return (t 1 , t 2 ) with t 1 t 2 ,
(2) Coherent waits: for every timestamp t 1 the action

waitUntil t 1 > > getRealTime shall return t 2 with t 1 t 2 .
The first property states that time shall flow from the past to the future. The second one states that a waitUntil action shall never resume before the expected timestamp is actually passed for real.

The IO example. (threadDelay

• fromInteger • toInteger ) (d -r )}
where Micro is a type of durations measured in microseconds.

Derived timed monad instance

Deriving a timed monad instance from a monad with timing information can then be achieved by extending the (implicit) monad state by an explicit timestamp.

More precisely, we define the timed action data type: This eventually provides the expected default timed monad extension of a monad m with timing information.

data
The correctness of such a construction, that is, the fact that laws (1)-( 15) are satisfied by TA m d under the restriction described in 2.4, can easily be proved from the above code and the hypothesis made on m, d and t. More precisely, the standard monad laws follow directly from the fact that TA m d is a simple variation on a classical state monad transformer. Thanks to property (1) assumed for getRealTime, durations are always positive. Then, timed laws follow from the way all the above defined functions act on timestamps.

More on temporal correctness issues

One can observe that run initializes the time drift with a positive (if not zero) value since the initial specified timestamp is set to the actual timestamp. Thanks to property (2) on waitUntil , one can also observe that delays always resume after the specified timestamp is actually passed for real. It follows that the time drift after a delay is always positive. Since every other primitive timed action has an actual duration greater than its specified duration, it follows that:

(1) the time drift is always positive, as easily proved by induction on the syntactic complexity of timed monad actions built from timed monad primitives. In other words, the action scheduling in the default instance is made in such a way that no action is actually scheduled before its specified scheduling time.

Temporal correctness also requires that such a time drift is bounded. Here, we can only observe that, obviously, in the general case:

(2) nothing ensures the time drift is bounded.

Indeed, as already mentioned, lifting a blocking IO action as an instantaneous one immediately induces an unbounded time drift. We shall discuss such an issue in the conclusion.

The IO example. As a particular case, the default timed extension of the IO monad, we call TIO, is simply defined by: type TIO = TA IO Micro with the instance TimedMonad IO Micro TIO deriving from the above instance HasTimer IO Micro.

Symbolic timed extension of a monad

We consider now the case of a time scale for the programmer distinct from the timescale of the underlying monad. More precisely, given an inner time scale, e.g. the physical time, measured by some inner duration type i, we aim at offering a symbolic timescale measured by some outer duration type o. This requires having some type s for measuring the possible speed (or tempo) of outer durations w.r.t. to inner durations.

Inner and outer durations with tempi

The relationship between duration types i , o and tempo s, when time speed is assumed to be piecewise constant, is conveniently modeled by the following type class:

class (Num i , Num o, Num s) ⇒ ScaleChange i o s | s → i , s → o where initialSpeed :: s step :: s → i → o backStep :: s → o → i
where initialSpeed is some fixed initial speed value, step s i that essentially computes the outer duration obtained by "multiplying" the speed s by the inner duration i , and backStep s o that essentially computes the inner duration obtained by "dividing" the outer duration o by (some non zero) speed s. The way these "multiplication" and "division" are actually performed shall depend on the chosen types. In the abstract, the following equations shall be satisfied by any instances:

backStep s (step s i ) ≡ i (18) step d (backStep d o) ≡ o (19)
for any inner duration i , outer duration o and non zero speed s, up to the possible rounding errors due to changes of numerical types. As a consequence, the function mapping the inner timescale Time i to the outer timescale Time o shall be bijective (up to rounding) and, in case step and backStep functions are truly implemented as some multiplication and division, piecewise linear.

The IO example. As an instance example, one can define:

newtype Beat = Beat Double deriving (Eq, Ord , Show , Num) newtype BPM = BPM Double deriving (Eq, Ord , Show , Num) instance ScaleChange Micro Beat BPM where initialSpeed = BPM 60 step

(BPM t) (Micro d ) = Beat $ t * ((fromInteger • toInteger ) d )/ratio backStep (BPM t) (Beat d ) = Micro $ fromInteger (floor (d * ratio /t))
with ratio = 60 * 10 6 , the time speed being expressed in beats per minutes (bpm).

Derived symbolic timed monad instance

A symbolic timed extension of a monad can then be built quite like the default timed extension described above. Indeed, we define symbolic timed states by: data ST i o s = ST {innerTime :: Time i , outerTime :: Time o, speed :: s } with symbolic timed actions defined by:

data STA m i o s a = STA (ST i o s → m (ST i o s, a))
This eventually yields the instance TimedMonad m o (STA m i o s), defined essentially like the instance of TA m d , taking care however to maintain coherent inner and outer timestamps in every symbolic timed state. This can be done without any real difficulty, laws ( 18)-( 19) ensuring, for a given time speed s, coherent back and forth translation between duration types i and o.

The IO example. As a particular case, the promised musically timed extension of the IO monad is defined by: type MusicIO = STA IO Micro Beat BPM

The underlying tempo can be changed at any time by the following parameterized timed action: setTempo :: BPM → MusicIO () setTempo t | t 0 = error $ "setTempo : forbidden negative tempo" setTempo t = STA $ λs → let ST ti to = s in return (ST ti to t, ()) Given function f ::Int → Note, our initial example can then simply and correctly be encoded by: playInIO = run playMusic playMusic ::

(Int → Notes) → Int → MusicIO () playMusic f n = do {lift (playNote (f n)) 1; delay 1; playMusic f (n + 1)} playNote :: Note → Beat → MusicIO () playNote n d = startNote n > > delay d > > stopNote n
By construction, the tempo has been initialized to 60 bpm, that is, one beat per second.

Timed promises

One may ask how robust our constructions of timed monads are, or, more precisely, to which extent additional features of a given monad can be lifted to its timed extension. We shall describe here the case of asynchronous concurrent promises that can uniformly be lifted from any monad where they are defined to its (default) timed extension when there is one.

Monad references

Since the 70s, there is the concept of promises that successfully extends functional programming to asynchronous concurrent features. Simply said, a promise is a place holder returned by a forked program that is eventually fulfilled by the value returned by that program [START_REF] Robert | Multilisp: A language for concurrent symbolic computation[END_REF].

In Haskell, the notion of promise is conveniently replaced by the notion of monad references [START_REF] Janin | An equational modeling of asynchronous concurrent programming[END_REF] where the action fork m shall fork the monad action m and immediately returns a reference to that action, the action read r shall return the value produced by the running action referenced by r as soon as it is available, the action tryRead r shall be a non blocking version of read r and the action parRead r 1 r 2 shall take two monad references r 1 and r 2 as parameters and return the value of the first referenced action that terminates, or either of the values if both are already terminated or are terminating at the same (or indistinguishable) time.

The basic (non-concurrent) semantics of monad reference basic primitives is governed by the following laws:

(fork m) > > = read ≡ m (20) fork • read ≡ return (21) fork (m > > = f ) ≡ (fork m) > > = λr → fork (read r > > = f ) (22)
for every m :: m a, f :: a → m b. Other laws, specifying the expected concurrent semantics of monad references are detailed in the companion article [START_REF] Janin | An equational modeling of asynchronous concurrent programming[END_REF]. One can observe that in all read actions above, variable t refers to the (specified) timestamp at which the referenced action is eventually completed while variable s refers to the (specified) timestamp at which the read action is called. As these two timestamps refer to independant events, we need to compute the (specified) timestamp max s t right after which these two events have occured. Then, one can check that equations ( 20)-( 22) are satisfied, even though this requires equivalent actions to also have the same (specified) duration.

Timed monad references

Remark. With the above proposed instance, nothing ensures the function parRead returns the value of the soonest terminated action as specified by termination timestamps. Indeed, the function parRead is non deterministic in two cases, the first one being when two referenced actions are already terminated, the second one being when there are terminating almost at the same time. Clearly, the first case can easily be solved by performing a tryRead on the second reference right after the first one is received and, if terminated, sorting the returned values according to their timestamp. However, the second case is more tricky to solve. One solution is to ensure that function tryRead returns Nothing only in the case the referenced action provably terminates later than the specified time at which tryRead is launched. Such a possibility is however yet not implemented.

Time specific action on timed monad references

The reader may have observed that, in the code above, we do not use the timestamp recorded in a timed reference when forking an action. Its relevance appears in the function durRef given below, from which various timed specific actions are derived.

(d → d ) → TRef m d a → TA m d a expandRef f r = do {t 1 ← now ; d ← durRef r ; a ← read r ; t 2 ← now ; let d 1 = f d -duration t 2 t 1 in delay d 1 ;
return a } where durRef returns, when finished, the specified duration of a referenced action, replayRef replays the referenced action from start, with the same duration but no side effect, and expandRef replays a referenced action but expanding (or shrinking) its duration by appliying some function parameter f .

Observe that all these actions can be used as soon as their parameters are available therefore even before the referenced actions are terminated and there specified durations are known. This means that shrinking a duration may fail to be done correctly as illustrated by fork m > > = expandRef ( /2) that unsucessfully tries to replay twice faster a just forked action. Such a resulting action is not temporal causal or, equivalently, duration d 1 in the code of expandRef is strictly negative hence no delay is applied. Executing a negative delay is here a clear sign of a causality error, an error that could well be raised as such.

As already observed in music experiments conducted along a previous modeling of interactive music by temporal tiles [START_REF] Archipoff | Structured reactive programming with polymorphic temporal tiles[END_REF], programming interactive music systems, these functions yield a completely new branch of realtime musical effects, such has repeating every note with its same duration, an effect that is essentially not available in the existing reactive music application software.

6 Data flow programming with timed monad streams Defining data flows by means of nested monad actions is a technique that is getting more and more popular for data-flow-like programming within generic functional programming languages as illustrated by Snoyman's Conduit library. Following the (simpler) definition of monad streams recently (re)defined and developed for audio processing and control [START_REF] Janin | Screaming in the IO monad[END_REF], there is the type constructor:

newtype Stream f a = Stream {next :: f (Maybe (a, Stream f a))} either defining monad streams with f = m for some monad m, or defining references to (running) monad streams with f = Ref m for some monad m with references [START_REF] Janin | An equational modeling of asynchronous concurrent programming[END_REF]. Then, as a derived function example, we have:

merge :: MonadRef m ⇒ Stream m a → Stream m b → Stream m (Either a b
) that merges two monad streams by order of arrival of their elements. Applied to timed monad and timed monad references, these kind of functions have clear application in timed data flow programming, especially for handling asynchronous control flows as recently illustrated [START_REF] Janin | Screaming in the IO monad[END_REF].

In other words, timed data flow programming automatically derives from timed monads and timed monad references. This somehow illustrates the fundational nature of these two concepts that both extend monads.

Related Works

In functional programming languages, there already are many proposals for programming timed reactive concurrent systems ranging from the synchronous language family [START_REF] De Simone | The synchronous hypothesis and synchronous languages[END_REF], possibly extended with modern polymorphism as with Reactive ML [START_REF] Mandel | ReactiveML, a reactive extension to ML[END_REF], to the many variants of functional reactive program (FRP) series initiated with FRAN [START_REF] Elliott | Functional reactive animation[END_REF][START_REF] Elliott | Push-pull functional reactive programming[END_REF][START_REF] Winograd-Cort | Settable and non-interfering signal functions for FRP: how a first-order switch is more than enough[END_REF]. However, to the best of our knowledge, most of these approaches consider a qualitative timing, as defined by series of events, instead of a quantitative timing that the programmer may specify as proposed here.

More precisely, the synchronous language approach mostly aims at defining timed programs over symbolic time scales (series of clock ticks) for which the actual duration between any two ticks is provably bounded. This eventually led to the successful development of programming languages such as Lustre or Esterel [START_REF] De Simone | The synchronous hypothesis and synchronous languages[END_REF] that allows programmers to implement (provably correct) synchronous realtime applications. Yet, programming timed applications with weaker but quantitative time specification seems to go out of the application scope of these languages, despite interesting extensions toward polymorphic and higher-order timing mechanisms [START_REF] Colaço | Towards a higher-order synchronous data-flow language[END_REF].

The FRP approach, somewhat more theoretical, aims at defining an adequate API for programming with timed signal. Initially designed to cope with arbitrary timescale [START_REF] Elliott | Functional reactive animation[END_REF], concrete implementations of FRP are mostly limited to reactive programming, though with some exceptions [START_REF] Nilsson | Functional hybrid modeling[END_REF]. In practice, timescales are defined by event arrivals, that act as qualitative clock ticks, function between signals being restricted to Mealy machines. There, the initially proposed API with signals defined as functions from timestamps to values yields (fairly easily) memory leaks which are avoided by such a restriction, either by syntactic means [START_REF] Van Der Ploeg | Practical principled FRP: forget the past, change the future[END_REF] or by modal type mechanisms [START_REF] Krishnaswami | Higher-order functional reactive programming without spacetime leaks[END_REF]. Our timed extension of monads, with derived timed monad streams, brings back qualitative time measurement between clock ticks without the associated time leaks.

The multitime scale approach, presented in Section 4 is an example of a fairly simple (piece-wise linear and locally finite) hybrid (bijective) signal. Along the lines proposed in [START_REF] Nilsson | Functional hybrid modeling[END_REF], it can probably be extended for defining more general hybrid signals, with their associated monitoring actions. Our approach is also influenced by Hudak's aim at defining temporal objects by means of the properties their combinators shall satisfy [START_REF] Hudak | An algebraic theory of polymorphic temporal media[END_REF]. Though our proposal eventually diverges from Hudak's polymorphic temporal media, it nevertheless inherits from its underlying intention to bridge the gap between theory and practice, as already illustrated by Euterpea [START_REF] Hudak | The Haskell School of Music : From signals to Symphonies[END_REF].

Last, the initial motivation for the present development of timed monads was to define an efficient and more generic programming interface for encoding temporal tiles [START_REF] Hudak | From out-of-time design to in-time production of temporal media[END_REF][START_REF] Archipoff | Structured reactive programming with polymorphic temporal tiles[END_REF]. As a matter of fact, all interactive music experiments conducted with such a model are easily and more efficiently re-implemented within the proposed timed monad framework. In particular, experiments with music control conducted within the symbolic timed IO monad defined in these pages yield a time drift smaller than 5ms therefore a resulting latency unnoticeable by human hears.

Conclusion

Along these pages, we have proposed and instantiated a fairly generic notion of timed extension of a monad. We have also shown how additional programming features of monads can simply be lifted into these extension. This time extension relies on distinguishing specified and actual duration: a distinction already put in practice in interactive music systems, the musician and the computer interacting one with the other [START_REF] Archipoff | Structured reactive programming with polymorphic temporal tiles[END_REF]. Of course, the topic is far from being closed, how to add timing information into interactive program being a vast subject. On the positive side, our proposal allows for clearly identifying what are the yet unsolved timing problems and where to look for solutions.

As already observed in 3.3, nothing ensures that the time drift is bounded in a timed monad action. The reader might be disappointed by such a fact. However, ensuring that a given program has a bounded time drift is a well-known tricky issue, undecidable in the general case. What restrictions on programs may yield timed actions with provably bounded time drift is a long standing research problem [START_REF] De Simone | The synchronous hypothesis and synchronous languages[END_REF]. Clearly, recursively defined action shall only be allowed when each recursive call is both terminal, in order to avoid a (stack) memory leak, and guarded by some sufficient long delays, in order to avoid a time leak. One possibility could be to extend modal types [START_REF] Krishnaswami | Higher-order functional reactive programming without spacetime leaks[END_REF] with quantified durations. Existing results in quantitative temporal logic may help. Also, extending the underlying monad actions type by some bound on their actual durations might help as well. This would allow checking that actions are properly lifted with adequate delays. Indeed, as already observed, lifting a blocking action as an instantaneous action is nonsense. Similar techniques should probably be used for detecting temporally non causal transformations as illustrated in 5.3 example.

As also observed in 2.4, two actions in a base monad m can be equivalent while their timed lifting is not. Indeed, with durations measured in microseconds, it is very unlikely that two distinct but equivalent actions have the same duration. Real time measurement is a property killer. One partial solution might be to measure time drift with less accuracy. In a music system, with symbolic time, such a problem is well-known. It arises when aiming at translating back realtime performances into music scores, as in score followers [START_REF] Giavitto | Time, timelines and temporal scopes in the Antescofo DLS v1.0[END_REF]. Rephrased in terms of timed monad, the implementation of drift is the key to handling such a problem. Is there any time drift between two different musicians performing the same score ? Measurements say yes, but listeners say no. The measurement of the time drift should follow listeners.

Of course, developing programming languages towards application in music may sound a bit pointless compared to applications with more economical impact such as, say, autonomous vehicles or connected objects. Is that so ? Clearly, experiments are easier to conduct in music than in most other application fields, with less dramatic consequences in case of errors. Moreover, time is known and handled by musicians for centuries. As illustrated throughout, various musical concepts can be generalized or abstracted into useful timed programming concepts. Our approach is hopefully abstract enough to be potentially applicable to other areas. Timed programming, with its need for automatic handling of time drift, is surely in the close neighborhood of spacetime programming, with its need for automatic handling of spacetime drifts.

3. 1

 1 Monads with timer Monads with timing informations are defined by the following class type: class (Ord d , Num d , Monad m) ⇒ HasTimer m d where getRealTime :: m (Time d ) waitUntil :: Time d → m () getDrift :: (Time d ) → m d getDrift t = do {r ← getRealTime; return (duration r t)}

  TA m d a = TA (Time d → m (Time d , a)) over a monad m :: * → * and a duration type d :: * , from which we derive: instance (Monad m, HasTimer m d ) ⇒ Monad (TA m d ) where return a = TA (λs → return (s, a)) TA m > > = f = TA (λs → m s > > = λ(s 1 , a) → let (TA m 1 ) = f a in m 1 s 1 ) and instance (Monad m, HasTimer m d ) ⇒ TimedMonad m d (TA m d ) where now = TA (λs → return (s, s)) drift = TA $ λs → getDrift s > > = λd → return (s, d ) delay d | d 0 = return () delay d | d > 0 = TA $ λs → do {dr ← getDrift s; waitUntil (shift s (d -dr )); return (shift s d , ())} lift m = TA $ λs → m > > = λa → return (s, a) run (TA m) = getRealTime > > = m > > = λ( , a) → return a

  specified as follows: class Monad m ⇒ MonadRef m where type Ref m :: * → * fork :: m a → m (Ref m a) read :: Ref m a → m a tryRead :: Ref m a → m (Maybe a) parRead :: Ref m a → Ref m b → m (Either a b)

  Equipping a timed extension of monad by monad references, as soon as the underlying monad itself has references, is (almost) easy as shown by the following instance: data TRef m d a = TRef (Time d ) (Ref m (Time d , a)) instance (MonadRef m, HasTimer m d ) ⇒ MonadRef (TA m d ) where type Ref (TA m d ) = TRef m d fork (TA m) = TA $ λs → do {r ← fork (m s); return (s, TRef s r )} read (TRef r ) = TA $ λs → do {(t, a) ← read r ; return (max s t, a)} tryRead (TRef r ) = TA $ λs → do {c ← tryRead r ; case c of Nothing → return (s, Nothing) Just (t, a) → return (max s t, Just a)} parRead (TRef r 1 ) (TRef r 2 ) = TA $ λs → do {c ← parRead r 1 r 2 ; case c of {Left (t, a) → return (max s t, Left a); Right (t, b) → return (max s t, Right b)}}

  durRef :: TRef m d a → TA m d d durRef (TRef t 0 r ) = TA (λs → do {(t, ) ← read r ; return (max s t, duration t t 0 )}) replayRef :: TRef m d a → TA m d a replayRef r = do {t 1 ← now ; d ← durRef r ; a ← read r ; t 2 ← now ; delay (d -duration t 2 t 1 ); return a } expandRef ::

  There, the functional dependencies t → m and t → d ensure that both the initial monad m and the duration space d are uniquely determined by the timed monad t.

	Num d , Monad m, Monad t)
	⇒ TimedMonad m d t | t → m, t → d where
	now :: t (Time d )
	drift :: t d
	delay :: d → t ()
	lift :: m a → t a
	run :: t a → m a
	that describes a timed monad t :: * → * that extends a monad m :: * → * with
	duration measured over some type d :: * .

  As an instance example, thanks to the System.Clock and Control .Concurrent libraries in Haskell, one can put: newtype Micro = Micro Int deriving (Show , Eq, Ord , Num)

getSystemTime :: IO (Time Micro) getSystemTime = do {t ← getTime Monotonic; (return • Time • fromInteger ) (div (toNanoSecs t) 1000)} instance HasTimer IO Micro where getRealTime = getSystemTime waitUntil (Time d ) = do {Time r ← getSystemTime;

A careful reading of this code shows that the resulting specified duration of a timed lifted action is, more precisely, the actual duration of its execution minus the existing time drift right before its execution.


E Esbelin

Graphite monochromator for actinide L-line energy dispersive X-ray fluorescence analysis in liquid sample

Introduction

The analysis laboratory in the CEA Atalante complex at Marcoule performs analyses for numerous R&D studies carried out in glove-boxes (intermediate activity) or in hot cells (high activity). The samples are measured in the liquid phase, either aqueous (mainly concentrated nitric acid media) or organic (TBP 30%/TPH 60% v/v for example). For radioactive samples derived from high-level tests, which can have very high radioactive dose rates, analyses are preferably carried out in shielded cells. The concentration of the main actinides of interest (U, Np, Pu, Am and Cm) are determined by XRF (X-Ray Fluorescence) in a hot cell using a device built specifically for these actinides analyses via their L line X-ray between 13 and 15 keV. In order to limit the counting rate of many radioactive emitters (Xray and gamma emitters) in the analysis solution and the continuous spectrum, a graphite monochromator is placed between the sample and detector.

Commercial or freesoftware packages available for processing X-ray spectra are usually designed and dedicated to a specific instrument and/or do not take into account the specific feature of our system: the presence of a monochromator. Mathematical modeling of the spectrum takes into account the relative X-ray emission rates of elements, but in the presence of the monochromator, these ratios are changed in appearance. The difficulty of correctly describing our system led us to develop new X-ray analysis software for this particular system. Until now in our laboratory, X-ray fluorescence analysis was restricted to samples with the same matrix used for the calibration. Dilution of samples for analysis is commonly used to conform to a known matrix. However, the analyzed media constantly vary depending on the R&D studies in progress, and when the actinide concentrations are low (on the order of 1 mg•L -1 ) in these samples, dilution is not a suitable option and it is essential to take the change of matrix into account. Similarly, when one of the elements constituting the sample has a high concentration (>1 g•L -1 ), absorption phenomena were not taken into account and only the dilution could allow a relevant analysis. The new algorithm implemented takes these remarks into account. This article describes the new semi-empirical model in place in the laboratory. This software was developed using Python(x,y), a Scientific-oriented Python Distribution based on Qt and Spyder [START_REF]Python(x,y): a scientific-oriented Python distribution based on Qt and Spyder[END_REF]. It has a user-friendly interface and is relatively simple for daily use and for X-ray spectrum fitting of many samples in different media.

Experimental

The X-ray generator and X-ray tube (Rh anode, 3 kW, 75 µm) are marketed by PANalytical. Two X-ray tube configurations are used in the laboratory: 50 kV/30 mA and 30 kV/10 mA. The primary X-ray photon beam is filtered by an Rh target (200 µm) producing an almost monochromatic beam. The detector is a hyper-pure Ge crystal (Eurisys EGX 30-05, active area 30 mm 2 ) cooled with liquid nitrogen. The acquisition electronics were recently replaced by a Canberra DSA-1000 coupled with Genie 2000 software. The sample is transferred pneumatically from a shielded cell to the analytical equipment. The device, located behind the shielded line, is also fully shielded (Pb protection). Figure 1 schematically illustrates the device used for this study. This system was designed in the 1990s. The samples are packaged in small polypropylene vials 1.5 cm in diameter and 1.5 mm thick. The primary X-ray beam reaches the sample vial laterally after passing through a mylar window not represented on figure. Given these dimensions, the sample is regarded as thick. Moreover, the presence of many attenuators along the X-ray beam limit the actinide quantification threshold to about 0.5 mg•L -1 .

The shape of the monochromator is cylindrical. It is made with thin strips of graphite on inner area. In order to avoid direct X-ray, two tungsten discs with smaller diameter are on every end of cylinder on the axial position. This device was custom-made. Thus, the studied energy range is restricted by this monochromator, and the elements of interest (U, Pu, Np) in this range have one L-line with an apparent emission rate exceeding 95%. For example, only the L3O45 lines between 13.6 and 14.3 keV are visible for U and Pu respectively, while their theoretical emission rates are 44% and 45% respectively. For an X-ray beam at 50 kV and 30 mA, their respective L3O1 lines at 17.2 and 18.3 keV, with theoretical emission rates of 23% and 21% are visible only at concentrations greater than 5 g•L -1 and represent less than 5% of the apparent total emission. For an X-ray beam at 30 kV/10 mA and up to 10 g•L -1 in U or Pu, no secondary line is visible; for a 20 g•L -1 Pu concentration, the secondary lines represent less than 0.2‰ of the maximum intensity of the main line.

Analysis of high atomic number elements in a limited energy range through a monochromator makes our system very specific: the "apparent" element spectrum contains only a single main line. Experience has shown that the secondary fluorescence phenomena are negligible, and they are therefore disregarded in the remainder of this article. The name of this device "L-line ED-XRF" is based on its specificity: the use of a monochromator in order to focus on energetic range corresponding to L-line X-ray of actinides.

Data Processing

Most available free or commercial software for XRF data processing are dedicated to a specific device and/or are based on the use of relative X-ray emission rates of elements. In our case, these ratios are changed in appearance by the presence of a monochromator. Then homemade processing software has been developed [START_REF] Esbelin | Graphite monochromator for actinide L-line energy dispersive X-ray fluorescence analysis in liquid sample X-ray[END_REF].

The basic principle is to deconvolute spectrum as a linear combination of elementary spectra (see Figure 2). The resulting fit is very close to the experimental curve. Some fission products such as Rb, Sr, Y, Zr are also analyzed (via their K-lines) in the energetic windows of monochromator. For that, a library of standard samples has been needed. This library is not a simple storage of standard spectra fingerprint. For each standard element, calibration is realized for every channel (multichannel analyzer) linking intensity and concentration by a nonlinear function (because of autoattenuation effect for the highest concentration). Thus the calibration file is a huge array with all parameters of calibration function for every channel and every standard.

A new approach has been proposed for matrix correction effects. Similar to that of Lachance-Traill established for solid sample, this approach is dedicated to liquid sample. This correction requires a good description of the analyzed sample matrix and the use of data from the XCOM mass attenuation coefficients database [START_REF] Berger | XCOM:photon cross sections on a personal computer U.S. Departement of Commerce[END_REF]. Another benefit of this correction establishment is the possibility to use calibration file with another sample matrix that one of standard sample. For example, an organic sample can be analyzed with a good estimation providing that the matrix can be accurately described. This is particularly useful for our R&D studies because a rapid estimation of results can be obtained without a long time calibration process.

An example is given in Table 1: a dissolution test of spent fuel residues in presence of a high amount of AgO (~100 g/L) in HNO3 6 M media was realized. Calibration was done in HNO3 3 M media. Matrix effects correction take into account the presence of AgO and the difference in acid concentration.

Estimated uncertainty

The estimation of the uncertainty is a delicate step. To date, we have studied the dispersion due to the positioning of the vial in the counting station, and the electronics and detector. This dispersion is less than 2 %. Nevertheless, a lot of parameters are involved in the uncertainty such as the calibration parameters, the number of selected element in deconvolution process, etc. The study is still in progress in our laboratory. Right now, an uncertainty of the order of 10 % is retained by feedback.

Conclusion

This device is suitable for actinide analysis (U, Np, Pu, Am, Cm) in the range 0.5 mg/L to 20 g/L. Other element, via their K-line, are analyzed in the energetic windows of monochromator such as Br, Rb, Sr, Y, Zr. The data process needs a good knowledge of sample matrix in order to correctly apply the matrix effect correction.

Figure 1 .

 1 Figure 1. Simplified diagram of the nuclearized high activity X-ray fluorescence device. The collimator between the vial and the monochromator is not represented.

Figure 2 .

 2 Figure 2. Spectrum of a sample taken in a test of liquid-liquid extraction on nuclear fuel dissolution solution.

Table 1 . Validation of proposed method.

 1

	Described	Selected	EDXRF (mg.L -1 )	ID-TIMS	Relative deviation
	media used for	element			(mg.L -1 )	(%)
	correction		Without	With		Without	With
			correction	correction		correction	correction
	HNO3 6 M	U	33.3	102.8	109.2 ± 2.2	69.5	5.9
	AgO
	100 g.L -1	Pu	18.7	57.8	59.8 ± 1.2	68.7	3.3