From 9c7e7572f0d57eff5f5aebf00b8ed6aba7a6dc37 Mon Sep 17 00:00:00 2001 From: Antony Lewis Date: Mon, 10 Jun 2024 16:31:20 +0100 Subject: [PATCH] add sigma8 example --- docs/CAMBdemo.html | 334 +++++++++++++++++++++++--------------------- docs/CAMBdemo.ipynb | 286 ++++++++++++++++++++----------------- 2 files changed, 329 insertions(+), 291 deletions(-) diff --git a/docs/CAMBdemo.html b/docs/CAMBdemo.html index abc06049..ea43e252 100644 --- a/docs/CAMBdemo.html +++ b/docs/CAMBdemo.html @@ -7331,12 +7331,11 @@ if (!diagrams.length) { return; } - const mermaid = (await import("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs")).default; + const mermaid = (await import("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.6.0/mermaid.esm.min.mjs")).default; const parser = new DOMParser(); mermaid.initialize({ maxTextSize: 100000, - maxEdges: 100000, startOnLoad: false, fontFamily: window .getComputedStyle(document.body) @@ -7407,8 +7406,7 @@ let results = null; let output = null; try { - let { svg } = await mermaid.render(id, raw, el); - svg = cleanMermaidSvg(svg); + const { svg } = await mermaid.render(id, raw, el); results = makeMermaidImage(svg); output = document.createElement("figure"); results.map(output.appendChild, output); @@ -7423,38 +7421,6 @@ parent.appendChild(output); } - - /** - * Post-process to ensure mermaid diagrams contain only valid SVG and XHTML. - */ - function cleanMermaidSvg(svg) { - return svg.replace(RE_VOID_ELEMENT, replaceVoidElement); - } - - - /** - * A regular expression for all void elements, which may include attributes and - * a slash. - * - * @see https://developer.mozilla.org/en-US/docs/Glossary/Void_element - * - * Of these, only `
` is generated by Mermaid in place of `\n`, - * but _any_ "malformed" tag will break the SVG rendering entirely. - */ - const RE_VOID_ELEMENT = - /<\s*(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\s*([^>]*?)\s*>/gi; - - /** - * Ensure a void element is closed with a slash, preserving any attributes. - */ - function replaceVoidElement(match, tag, rest) { - rest = rest.trim(); - if (!rest.endsWith('/')) { - rest = `${rest} /`; - } - return `<${tag} ${rest}>`; - } - void Promise.all([...diagrams].map(renderOneMarmaid)); }); @@ -7551,7 +7517,7 @@
@@ -7672,7 +7638,7 @@
@@ -7740,7 +7706,7 @@
@@ -7789,7 +7755,7 @@
@@ -7805,9 +7771,7 @@
# Now get matter power spectra and sigma8 at redshift 0 and 0.8
 # parameters can all be passed as a dict as above, or you can call 
 # separate functions to set up the parameter object
-pars = camb.CAMBparams()
-pars.set_cosmology(H0=67.5, ombh2=0.022, omch2=0.122)
-pars.InitPower.set_params(ns=0.965)
+pars =  camb.set_params(H0=67.5, ombh2=0.022, omch2=0.122, ns=0.965)
 #Note non-linear corrections couples to smaller scales than you want
 pars.set_matter_power(redshifts=[0., 0.8], kmax=2.0)
 
@@ -7892,7 +7856,7 @@
 
 
@@ -7905,6 +7869,46 @@
In [11]:
+
# If you want to use sigma8 (redshift zero) as an input parameter, have to scale the input primordial amplitude As:
+
+As = 2e-9 # fiducial amplitude guess to start with
+pars =  camb.set_params(H0=67.5, ombh2=0.022, omch2=0.122, ns=0.965, As=As)
+pars.set_matter_power(redshifts=[0.], kmax=2.0)
+results = camb.get_results(pars)
+s8_fid = results.get_sigma8_0()
+# now set correct As using As \propto sigma8**2.
+sigma8 = 0.81 # value we want
+pars.InitPower.set_params(As=As*sigma8**2/s8_fid**2, ns=0.965)
+
+# check result
+results = camb.get_results(pars)
+print(sigma8, results.get_sigma8_0()) 
+
+
+
+ + +
+ + +
+
+