Large deviations of currents in diffusions with reflective boundaries

We study the large deviations of current-type observables defined for Markov diffusion processes evolving in smooth bounded regions of $\mathbb{R}^d$ with reflections at the boundaries. We derive for these the correct boundary conditions that must be imposed on the spectral problem associated with the scaled cumulant generating function, which gives, by Legendre transform, the rate function characterizing the likelihood of current fluctuations. Two methods for obtaining the boundary conditions are presented, based on the diffusive limit of random walks and on the Feynman--Kac equation underlying the evolution of generating functions. Our results generalize recent works on density-type observables, and are illustrated for an $N$-particle single-file diffusion on a ring, which can be mapped to a reflected $N$-dimensional diffusion.


Introduction
The main property of nonequilibrium systems that distinguishes them from equilibrium systems is the existence of energy or particle currents produced by non-conservative internal or external forces, or coupling to reservoirs at different temperatures or chemical potentials [1]. These currents and their fluctuations have been the subjects of many studies in the last decades, owing to their importance in biological transport phenomena [2,3], and the existence of fundamental symmetries, referred to as fluctuation relations, which constrain the probability distribution of current-like quantities, such as the entropy production [4][5][6].
Similarly to equilibrium systems, the fluctuations of observables, such as currents, can be studied for nonequilibrium systems using the theory of large deviations, which provides a number of general techniques for obtaining the distribution of observables in a given scaling limit (e.g., low-noise, long-time or large-volume limit) relevant to the system studied [7][8][9]. Many of these techniques were successfully applied in recent years for Markov models of physical interest, including random walks, interacting particle models, such as the exclusion and zero-range models, as well as Markov diffusions described by stochastic differential equations (see [10][11][12][13] for useful reviews).
In this paper, we study the large deviations of Markov diffusions evolving in bounded domains of R d with reflection at the boundaries. Such processes are encountered in many applications, including in biology where they model the diffusion of nutrients within cells [14], and have been studied before in large deviation theory, though either in the low-noise limit [15][16][17][18] or for density-type observables defined as time integrals of the state of the process [19][20][21][22][23][24][25][26][27]. Here, we consider the long-time or ergodic limit and focus on current-type observables, defined as integrals of the state and increments of the reflected diffusion. For these, we show how the large deviation functions (viz., scaled cumulant generating function and rate function) characterizing the fluctuations of observables can be obtained from a spectral equation that must be solved with special boundary conditions, taking into account the reflection of the process at the boundaries and the fact that the observable is current-like.
These boundary conditions generalize those found recently for density-type observables [27] and are non-trivial in that they cannot be obtained by directly applying the duality argument used in [27]. This point is explained in the next section, following a summary of large deviation theory as applied to dynamical currents defined in the long-time limit. In the sections that follow, we then derive the boundary conditions using two different methods: one based on the diffusive limit of a random walk model, which has the advantage of being physically transparent, and another, more formal method based on the Feynman-Kac equation, which underlies the spectral equation, and a local-time formalism to describe the boundary behavior.
A consequence of the boundary conditions imposed on the spectral problem is that the stationary current of the effective or driven process, introduced recently as a way to understand how large deviations are created in time [28][29][30][31], vanishes in the normal direction of the boundaries or walls limiting the diffusion. This is a natural result given that the effective process corresponds, in an asymptotic way, to the original process conditioned on realizing a given fluctuation [31] and, therefore, should inherit the zerocurrent condition of the original process resulting from the reflections.
As an illustration of our results, we study the integrated particle current of a heterogeneous single-file diffusion, consisting of N driven, non-identical particles diffusing on a ring without crossings [32]. This model can be mapped to a non-interacting diffusion model in R N with a reflecting wall, for which the spectral problem can be solved exactly to obtain the scaled cumulant generating function and rate function of the current, characterizing its stationary value and fluctuations. Applications to other models, including diffusions with partial or sticky reflections at boundaries, are discussed in the final section of the paper.

Formalism in unbounded domains
We consider a d-dimensional Markov diffusion X(t) evolving in R d according to the stochastic differential equation (SDE) where the drift vector F depends on the state of the process, whereas the noise matrix σ multiplying the Wiener noise is constant. We define the diffusion matrix D = σσ T . The process density ρ(x, t) = Prob[X(t) = x | X(0) = x 0 ] evolves according to the Fokker-Planck (FP) equation expressed using the FP operator which acts on the domain of twice-differentiable, integrable densities. We assume the existence of a unique invariant density ρ * for which L † ρ * = 0. Time-dependent averages of functions f of the process evolve in time according to with the operator known as the Markov generator [33]. Using the standard inner product the Markov operators L and L † are related via the duality relation for arbitrary densities ρ and functions f for which the inner product is finite. We are concerned in this paper with time-integrated observables V T derived from the empirical current J T of the process. The empirical current at x is the number of passes through x (counted with sign) per unit time in a time window [0, T ]: The first line expresses a Stratonovich integral, defined as the discretization procedure shown in the second line, where i indexes time-points in [0, T ] separated by the vanishing duration ∆t. The rationale for using the Stratonovich convention is that the current is properly antisymmetric under time-reversal of trajectories and has an expectation equal in the long-time limit to the stationary current From J T (x), it is possible to define other current-like dynamical observables as where g is an arbitrary kernel vector field. Depending on the process and the choice of g, this observable can represent, for example, a particle or energy current, or the entropy production. The probability density P T (v) = Prob[V T = v] of such observables generally satisfies a large deviation principle for large ‡ observation times T , meaning that The rate function I(v) characterizes the exponential decay of fluctuations v, that is, sustained deviations of the observable from the typical value(s)v for which I(v) = 0. Dynamical large deviation theory is concerned with calculating the rate function and with describing via an effective process the subset of process realizations that give rise to any given fluctuation. Below we outline the basic elements of dynamical large deviation theory, referring to [31] for details and derivations. In order to calculate the rate function, we introduce the scaled cumulant generating function (SCGF) which is related to the rate function via Legendre-Fenchel (LF) transform, This assumes that I(v) is convex, which is guaranteed, for instance, if λ(k) is continuously differentiable in k [9]. Furthermore, it can be shown (via the Feynman-Kac formula [13]) that the generating function where the subscript x indicates the initial condition X(0) = x, has a semigroup structure and evolves in time according to where the 'tilted' generator L k is given by Since the semigroup equation (15) is linear, we can decompose it in terms of the eigenvalues λ (i) k and eigenfunctions r Inserting this decomposition in the definition of the SCGF, we find in general that the SCGF is the dominant (Perron-Frobenius) eigenvalue of L k , so we can write as a shorthand r k being the eigenfunction associated with the dominant eigenvalue and SCGF λ(k) = max i Re λ (i) k . These spectral elements are also used in large deviation theory to define a new Markov diffusion, called the effective or driven process, with generator [31] whose invariant density is where k solves the dual eigenvalue problem with natural boundary conditions on R d . Here, L † k is related to L k via the duality (7) and is given explicitly by Note that the boundary conditions on r k are defined indirectly by imposing natural boundary conditions for the density ρ * k on R d . The effective process corresponds to a process with the same diffusion matrix as the original one, but with a modified drift When k is tuned according to that is, the maximizer in (13), then the effective process gives v as the long-time value of V T . In this way, this process can be interpreted as describing (asymptotically) the set of trajectories of the original process conditioned on V T = v (see [31] for a precise statement).
An analogy with equilibrium statistical mechanics can be established by noting that the tilted generator corresponds (asymptotically) to the generator of a non-conservative process constructed by penalizing the probability of every trajectory X(t) over [0, T ] by the weight factor exp[T kV T ] as T → ∞. This penalized distribution on trajectories is analogous to the 'canonical ensemble', bar the missing normalization [31]. Following this analogy, the SCGF can be seen as being analogous to a free energy density, while the rate function, obtained via the LF transform, is analogous to an entropy density [9]. The tuning (24) relates k to the inverse temperature in the canonical ensemble.

Introducing boundaries: constraints from duality
We now consider a domain Ω ⊂ R d which has a smooth boundary ∂Ω. In the interior of the domain, the process X(t) is still described by the SDE (1). Consequently, the operators L and L † are still given by (5) and (3), but must be supplemented with boundary conditions on the functions f and ρ on which they act, in order to account for the boundary behaviour.
These boundary conditions are related through the duality relation (7), but with an inner product integrating over Ω rather than over all of R d . Starting from Lρ, f and performing repeated integration by parts to shift the derivatives from f to ρ (see Appendix A), one finds wheren is the (inward) normal of ∂Ω and the probability current J F ,ρ is as defined in (9). In order for the operators L and L † to be well defined, independently of any particular ρ or f , it is necessary that the surface integral terms in (25) always vanish. A particular prescription that accomplishes this constitutes a boundary condition, and amounts to a restriction of the domains of the Markov operators. Note that if we put f ≡ 1, then the vanishing of the boundary term corresponds to conservation of probability as it represents the zero net current through the boundary.
In this paper, we are concerned with reflective boundaries. At the level of the FP equation, this means that the probability flow through the boundary vanishes at every point on the surface: From (25), we note that (26) implies that the boundary condition on f is which is equivalent to since D is symmetric by definition. Thus, unlike the current, ∇f does not vanish in the direction normal to the surface, but in the direction Dn, which is called the conormal direction [14,34]. We now turn to the large deviation elements associated with the current-like observable (10). Just as in the case without boundaries, we must solve the dominant eigenvalue problem (18) for L k and (21) for its dual L † k , but now with boundary conditions for r k and k on ∂Ω in some way determined by the reflective boundary of the original process. Clearly, these boundary conditions must be consistent with (26) and (27) for k = 0. In addition to this constraint, the duality relation for the eigenvectors should also hold for all k. Performing repeated integration by parts we find (Appendix B) where F k is the modified drift (23). Interpreting again k r k = ρ * k as the stationary density of an effective process with drift F k , the vanishing of the boundary term in (29) expresses the conservation of probability for the effective process.
On physical grounds, it is reasonable to suppose that if the original process has reflective boundaries, then so does the effective process, meaning that the boundary term in (29) vanishes because However, as we are about to see, this condition does not allow us to uniquely determine boundary conditions for r k and k separately. Indeed, we can write, for an arbitrary constant c, With this identity, the boundary term in (29) can then be made to vanish by imposing the following boundary conditions: for x ∈ ∂Ω and any c. The ambiguity arises from the fact that any boundary term proportional to k r k that vanishes as k → 0 can be split between the two conditions. In [27], which dealt with reflected diffusions conditioned on density-like observables, this ambiguity does not arise, because the 'tilting' of the generator does not produce any new boundary terms in the duality relation. An argument beyond assuming a reflective boundary for the effective process to satisfy the duality is therefore necessary to establish the correct boundary conditions. In the next sections we provide two independent methods, free from assumptions about the boundary behavior of the effective process: one based on taking the diffusive limit of a conditioned lattice problem with boundary (Sec. 3), and the other based on considering local time at the boundary in the Feynman-Kac formula that defines the tilted generator (Sec. 4). From both approaches, the boundary conditions emerge as These boundary conditions correspond to (32) with c = 1/2 and consequently prove that the effective process indeed possesses a reflective boundary, as described by (30). It is striking that the boundary conditions are 'tilted' in the same manner as the tilted generator itself by letting ∇ → ∇ + kg for r k and −∇ → −∇ + kg for k . Furthermore (33b) implies that, on the boundary, the normal component of the effective drift coincides with the original drift: This situation was shown to hold also for the large deviations of density-like observables in the presence of a reflecting boundary [27]. Finally, we remark that in the special case of an observable satisfying the tilted boundary conditions (32) take the same form as the original ones, i.e., (26) and (27), and are independent of c. The condition (35) is a necessary condition for the tilted generators to be symmetrizable.
3. Boundary conditions from the diffusive limit

Tilted lattice model
A strategy to derive the correct boundary conditions on r k and k is to consider the original diffusion as the limit of a jump process [35]; that is, to set up a sequence of jump process N(t) on a lattice structure L , parametrized by the site separation a, together with a lattice-current observable A T . The transition rates of the jump process are taken to scale with a such that a diffusive limit exists, giving as a → 0, L → Ω, N(t) → X(t), and A T /a → V T . Then also the spectral elements associated with the conditioning on A T map from lattice to continuum, giving in this limit bulk and boundary equations for k and r k . For simplicity, we suppose L to be a cubic lattice with a planar boundary. Since the boundary ∂Ω converged to is always locally planar (because it is smooth), this is not an essential limitation. The process N(t) evolving on L is then a random walk, as defined in Fig. 1. For each i labelling a spatial axis, the hopping rate is p i (n) forwards and q i (n) backwards. The hopping rate into a boundary vanishes, which can be interpreted as reflection, as explained in Fig. 1(c).
On the lattice, we consider an observable of the form where the empirical flow C T counts the number of transitions over the specified bond, and the function α(n | n) represents a weight associated with the empirical flow.
Because we seek to map A T onto the diffusion observable V T , we choose an antisymmetric α: α(n | n) = −α(n | n ).
We can then write (36) as whereê i is the single-site translation vector for axis i and J T (n | n) is the empirical lattice current, defined in terms of the empirical flow as The contraction of the current in (39) giving A T is the jump process analog of (10) for the diffusion, with α playing the role of g.
As for diffusions, the SCGF of A T corresponds to a dominant eigenvalue, this time of a |L | × |L | matrix L s with elements [31] L s (n , n) = W (n | n )e sα(n|n ) − δ n,n n W (n | n).
The non-zero transition rates in this expression are

Diffusive limit of the observable
The diffusive limit relating the master equation of N(t) to the FP equation of X(t) is defined by the following scaling relations [35]: where points in Ω relate to points in L as x = an. Equivalently, we may state To show that A T /a converges to V T in this limit, we first use the fact that α is antisymmetric to write where G is an arbitrary smooth function independent of a such that g i = ∂ x i G.
Next, we note that the lattice empirical current over the n → n +ê i bond is where the second line follows because N i (t + ) and N i (t − ) differ by precisely one step. We now discretize time into points t j narrowly separated by intervals ∆t(a), such that the jump process makes at most one jump in each interval for any value of the site separation a. For any such trajectory, δ N(t j ),n δ N(t j +∆t),n+ê i + δ N(t j ),n+ê i δ N(t j +∆t),n = δN(t j )+N(t j +∆t) which is seen from the fact that both sides are symmetric under exchange of N(t − ) and N(t + ). In the diffusive limit we replace N(t) = X(t)/a, δ n,n = δ(x/a − x /a), and thus as defined in (8). Hence

Diffusive limit of the spectral elements
We now derive the diffusive limit of the spectral elements, assuming the following diffusive scaling between the lattice and continuum elements: To begin, we consider the limit of the right eigenvalue equation, For n away from the boundary sites, Up to relevant orders in a, and suppressing the function arguments x and n, with L k as in (16). This recovers the spectral equation for r k in the bulk. Now let us take n to be a boundary site as in Fig. 1(b). Then Thus, including all relevant orders, where we have used (53) to neglect the sum on the i > 1 terms. In fact, the right-hand side of (55) is O(1/a). Substituting q i with (44b), multiplying both sides by a, and taking a → 0, we then arrive at which generalizes, including all other components, to Thus, we find the boundary condition (33b), corresponding to (32) with c = 1/2. Now that the boundary condition on r k has been established, the boundary condition (33a) for k follows uniquely from duality. One may also verify that this boundary condition follows from the diffusive limit of the left eigenvalue equation, in a calculation analogous to that of r k . Furthermore, the duality relation (29) is the result of applying the diffusive limit to the trivial identity n,n L s (n)L s (n, n )R s (n ) = n,n R s (n)L s (n, n )L s (n ). (58)

Boundary conditions from Feynman-Kac expectation
We provide in this section an alternative derivation of the boundary condition (33b) on r k , proceeding directly from the generating function u(x, t), as defined in (14), which, from its spectral decomposition (17), shares the boundary conditions placed on the eigenfunctions of L k . To account for the reflection upon reaching the boundary ∂Ω, we employ a formulation of reflected SDEs, introduced by Skorokhod [36] and Tanaka [37], based on the following modified SDE: The first two terms on the right-hand side describe the evolution of X(t) inside the domain Ω, whereas the last term pushes the process inside Ω in the direction of the unit vectorγ(x) in the event that the process reaches x ∈ ∂Ω. The extra random process L(t) accounting for the reflection is called the local time, since it is incremented only when the process reaches ∂Ω, and is known [38] to be such that Therefore, the increment dX(t) on x ∈ ∂Ω satisfies where we have used the fact that dW(t) = 0 for all t, and where = O( √ dt) such that dt( ) = O( 2 ). Here, we takeγ to be in the conormal direction, that is, This choice is necessary (see [39,Thm. 2.6.1]) to preserve the zero-current condition (26) associated with reflections.
Our goal now is to understand the effect of the boundary dynamics on the generating function u(x, t) of the observable V T , as defined in (14). To this end, we consider a point x ∈ ∂Ω and write the generating function as having isolated in the first integral the contribution from the reflection, which takes place over the infinitesimal time dt( ). Using the Stratonovich discretization, as in (8), we have so that The expression of the expectation can be written explicitly as using the conditional probability density of the first increment dX(0) from X(0) = x ∈ ∂Ω, which includes all the information about the reflections on the boundary. Using the definition of the generating function for the last factor in the integral, we then obtain At this point, we perform Taylor expansions in both space and time, starting with the one in space, which gives to first order in δ: This becomes given that and noting that δ = |dX(0)|. Moreover, since x ∈ ∂Ω, we have from (61) and (62), yielding Considering now the Taylor expansion in time, we have using the fact that dt( ) = O( 2 ). Therefore, we find using the fact that D is symmetric. This is the boundary condition satisfied by the generating function for all x ∈ ∂Ω. The eigenfunctions r k (x) of the tilted generator L k share the same boundary condition, so we have in the end which reproduces the boundary condition (33b), obtained also from the diffusive limit. The boundary condition on k can then be found in the usual manner via the duality relation (29), thereby recovering (33a). The same calculation can be performed, in principle, for an arbitrary reflection directionγ(x), in which case the boundary condition becomes Comparing with the duality relation (25) for k = 0 then shows that we only obtain the zero-current condition at the boundary when the chosen direction for reflection is the conormal direction, as mentioned before. It is also interesting to note that, if we repeat the calculation for a density-type observable of the form then the boundary condition is which is the result obtained in [27] using only the duality relation.

Exactly solvable example: Heterogeneous single-file diffusion on a ring
We illustrate the formalism and results developed in the previous sections for a singlefile diffusion model, recently solved for its steady state [32] similarly to earlier lattice models [40,41]. The model consists of N distinct point-particles moving on a ring S of circumference L, as illustrated in Fig. 2. Each particle i has a constant intrinsic velocity v i and a diffusivity D i = σ 2 i arising from white noise of strength σ i . The particles interact through volume exclusion: if one particle attempts to overtake another, that move is reflected. Collecting the (stochastic) particle positions X i (t) taking values in S into a vector X(t) on a domain Ω ⊂ S N , we obtain an N -dimensional diffusion of the form (1) where the drift F is the collection v = (v 1 , . . . , v N ) of intrinsic velocities, and D is the diagonal matrix diag{D 1 , . . . , D N }.
The boundary ∂Ω of the process consists of those configurations for which two (or more) particles are immediately adjacent. The hardcore exclusion rule translates into the reflective boundary condition (26). For two particles, for instance, the boundary consists of X 1 = X 2 , which in the space S 2 [0, L) × [0, L) is a diagonal with normal n = (ê 2 −ê 1 )/ √ 2 = (−1, +1)/ √ 2. Generalising to N particles, we then find that the boundary conditions arê The periodicity of the ring is implemented by the condition for the density, where 1 is the vector of ones, so that L1 is the translation vector moving all particles simultaneously by one period L.
It was shown in [32] that the invariant density of this process is This result assumes that x ∈ [0, L) N and that the ordering of particles is consistent with that of the initial condition, clearly conserved by the dynamics. Without loss of generality, we assume . . . x i−1 < x i < x i+1 < . . . (modulo L). The vector k has elements whereṽ satisfiesṽ It is clear from the geometrical constraints on the particles' motion that they must have a common net velocity in the long-time limit, corresponding in fact toṽ. If follows from (84) thatê independent of i, which confirms the interpretation ofṽ. Note that k · 1 = 0, which ensures the periodicity (83).
It is natural to consider as a current-like observable the empirical velocity of particle i, given by the ith component of the empirical current J T integrated over Ω. However, since all particles must have the same net velocity for long averaging periods, all observables of the form (10) with g a constant vector whose components sum to one (1 · g = 1) should have the same large deviations. To validate this claim, we keep g arbitrary apart from these constraints, and thus consider the current observable The empirical velocity of particle i is obtained by choosing g j = δ ij . To find the dominant eigenvalue λ(k) and eigenvector r k related to this observable, we consider as an ansatz with a to be determined. This ansatz is motivated by the fact that the dominant eigenvalue 0 for L † and L corresponds to eigenfunctions with an exponential form: (84) for the former, and trivially e 0 for the latter. We observe that 1 ·n(x) = 0 for all x ∈ ∂Ω, and that 1 is the only vector with this property. From the boundary condition (33b), we therefore find for some constant α. Hence a = 2αD −1 1 − kg.
The periodicity (83) requires a · 1 = 0, so that where we have used the property 1 · g = 1 and (86). Applying L k to r k , one then finds that r k is an eigenfunction with eigenvalue By LF transform, we then obtain the rate function which shows that the fluctuations of the current are Gaussian around the stationary velocityṽ.
The same eigenvalue (93) is obtained by assuming for the left eigenfunction for which we find, in a calculation analogous to the one for r k , It is interesting to note that the rate function (94) is equivalent to that of a single particle with driftṽ and diffusivity D. To better understand how current fluctuations are created, we can determine the effective drift F k of the conditioned dynamics using (23) and the expression for r k . The result is which gives for the probability current Thus, for the particle system to generate an atypical fluctuation of the collective current, each particle gives rise through fluctuation to an equal absolute increase in their intrinsic velocity, equal to ∆v = v −ṽ. The current thus changes uniformly. These results are consistent with the fact that the rate function saturates a universal quadratic bound on current fluctuations [42], and are also expected given that the heterogeneous single-file diffusion on a ring, while not satisfying detailed balance directly, does so with respect to a reference frame moving with the collective velocityṽ. As a result, the stationary density of the effective process (20) must be equal to the original invariant density (84): This can be checked more directly by noting that a + b = k.
To close, it is instructive to compare the results of the single-file diffusion model to those of the asymmetric simple exclusion process (ASEP) conditioned on a large current [43]. For that model, it was found analytically that asymptotically large currents are generated through an effective process comprised of two effects: a uniform increase in the hopping rate of all particles, and a pairwise repulsive interaction between particles, not present in the unconditioned process. Since the ASEP yields in the diffusive limit a single-file dynamics with identical particles, we conclude that the second effect is purely a lattice effect. Indeed, on the lattice, jammed configurations form a finite fraction of all possible system configuration, whereas on the continuum, jammed configurations constitute a boundary layer of measure zero relative to the bulk.

Discussion
We have provided two independent methods showing that for reflected diffusions, the correct boundary conditions for the spectral problem associated with the dynamical large deviations of current-like observables are given by (33). These boundary conditions are interesting in that they mimic the "tilting" of L and L † to L k and L † k , respectively. We indeed recall that L k is obtained from L by the replacement ∇ → ∇ + kg, while L † k is obtained from L † by the replacement −∇ → −∇ + kg. The same replacements, when applied to the condition (27) for f and the condition (26) for ρ, gives, respectively, the boundary condition (33b) for r k and the boundary condition (33a) for k . Based on this result, it is natural to conjecture that the same replacements apply to other boundary conditions describing other types of boundary behavior, e.g., partially reflecting [44] or sticky [45].
Two physically significant results follow from the boundary conditions (33). Firstly, they imply that the effective process, describing how current fluctuations are realized, also has reflective boundaries, but relative to the effective drift F k (23). This is expected: all system trajectories are reflected at the boundary and, therefore, so is any subset of trajectories corresponding to a given current fluctuation. The second, less obvious result is that the effective force at the boundary is not modified in the normal direction, as expressed in (34). A physical (as opposed to mathematical) understanding of why this is so may come from studying more specific model diffusions. Note that both results were also found for occupation-like observables in one-dimensional diffusions [27], so the type of observable considered (occupation-like or current-like) is not relevant for their explanation.
In our example of heterogeneous single-file diffusion conditioned on the collective particle current, the effective force changes in both magnitude and direction, but its projection onto the boundary normal does not. One can note that the original process has an irreversible drift [46], generally defined by F ir (x) = J * (x)/ρ * (x), which is a constant vector, everywhere orthogonal to the boundary normal. This property allows us to solve the model exactly [32], and explains why the irreversible drift of the effective process is only modified in magnitude [47]. To obtain more complicated and interesting behavior upon conditioning on a current, one could study models for which the irreversible drift does not have this special structure; looking, for instance, at non-planar boundaries and state-dependent original drifts. Our general results show how, in principle, one can calculate the large deviation elements in these cases. In any such model an interesting question will be the relative importance of the system bulk to the near-boundary region in generating fluctuations.

Appendix A. Duality for Markov operators
We show here the calculation leading to the duality relation for the Markov operators: when the process is constrained to a region Ω ⊂ R d . Before proceeding, we state for convenience a mathematical identity, which amounts to integration by parts in higher dimensions. For a scalar field u and vector field V we have wheren(x) is the inward normal vector at point x ∈ ∂Ω. Starting from the inner product over the domain Ω and using the expression (5)  where L † is defined as in (3). Recognizing the definition of the current (9) in the above, (A.1) follows.
dx J F k , k r k (x) ·n(x), (B.1) for the tilted generators for a process constrained to a region Ω ⊂ R d , proceeding in a similar manner as done in Appendix A. Using the expression (16) for the tilted generator, we have k , L k r k = Ω dx k (x) F (x) · (∇ + kg(x)) + 1 2 (∇ + kg(x)) · D(∇ + kg(x)) r k (x).
(B.4) The last term in the above contains no derivatives and produces no boundary terms, while the first term has already been dealt with in Appendix A in (A.5) and (A.7) (with the understanding that k and r k are to replace ρ and f , respectively). We can therefore immediately write (B.8) Noting from (22) that the expression in square brackets is simply the operator L † k applied to k , and observing that k r k F + kDg + 1 2 k D∇r k − 1 2 r k D∇ k = J F k , k r k (B.9) where we have used the definition of the current (9) and effective force (23), we obtain the duality relation (B.1).