text:
The featured image of this post is by Vladimir163rus on Pixabay.

A new Arduino library has seen the light of day: SingleWireSerial. It supports single-wire, asynchronous serial, half-duplex communication. By using the input capture feature of the AVR MCUs, it is extremely accurate and supports bit rates up to 250 kbps robustly. And contrary to its title, one can even use it in a two-wire setting.

## Background

Earlier this year, I worked on a hardware debugger making use of the debugWIRE protocol. But I couldn’t get it to work reliably. One problem seemed to be the serial communication using only one line (the RESET pin of the MCU). People had come up with different solutions, but none of them worked for me reliably. So, recently I set out to program my own solution that led to the SingleWireSerial library. It satisfies the following three requirements:

1. single-wire serial communication,
2. extremely accurate and robust up to 125 kbps,
3. communication speed can be set at runtime.

First, usually asynchronous serial communication is done using two wires. If one wants to restrict the communication to only one wire, this is possible. But then there should be a strict protocol about which party is allowed to transmit data. For instance, if a master is the one who sends requests or queries to which the slave responds, it is clear who is in the role of a sender at each point of time. This can all be solved on the software level. On the hardware level, one needs to come up with a solution that permits two parties to send and receive on one wire only. Or one addresses this problem at the software level too.

Second, if you want to transmit strings about the room temperature, then nobody gets annoyed when at some point of time the wrong temperature is displayed. When you are debugging a system and a wrong value is displayed because of a communication error, then one is, of course, upset. debugWIRE does unfortunately not have any form of error detection, so one has to rely on the fact that there is no communication error at all. Since the communication speed is set to the system clock divided by 128, at 16 MHz system clock the communication speed will be 125 kbps. So, we need error-free serial communication at 125 kbps!

Third, if the communication speed is known ahead at compile time, then picoUART is probably the best alternative. However, with debugWIRE we only learn about the communication speed at runtime. Furthermore, we want to get as close as possible to the communication speed the MCU has that we want to debug, which might diverge from the standard ones because the clock speed is controlled by an internal RC oscillator.

## Single-wire: Hardware or software solution?

You can create a single-wire serial solution basically in two ways. First, you can join the TX and RX lines somehow. Second, you have only one line from the beginning.

Joining TX and RX involves some external hardware. The Microchip application note AN2658 describes this in detail, employing two transistors–one inverter and one open collector driver. A similar effect can more simply be achieved by having a pull-up resistor attached to the RX line and a diode between the RX and TX line with the anode at the RX line, as is sketched in the next picture.

A high level on the TX line will have no effect, i.e., the common line will be pulled up by the resistor. A low level on the TX line will pull down the common line. However, depending on what type of diode one uses, it will only be pulled down to 0.3-0.7 volt. This should be enough for all practical purposes because CMOS chips detect a low level up to 0.3Vcc.

Using this bit of extra hardware allows employing a hardware UART. However, one annoying side effect of this hardware solution is that all sent bytes are also received and need to be ignored.

The second kind of solution uses bit -banging, i.e., one controls one pin through software. By switching the direction of a pin between input and output (with a low level), one creates an open drain output, similar to the one above. The usual software UART libraries do not support this out of the box. However, it is not very difficult to adapt them. OnePinSerial is such an adaptation of SoftwareSerial for use in a debugWIRE debugger. However, it is quite brittle. When the millis interrupt is enabled, which it is in the described debugger, then OnePinSerial does not receive reliably at 125 kbps. And even disabling the millis interrupt is not a 100% cure.

## Input capture and output compare match

One problem with bit-banging UART solutions is that one has to rely on knowledge about what kind of code the compiler produces in order to generate the right timing. And code generation might be different for different compiler versions. For instance, in the SoftwareSerial class, you find code that is compiled conditional on specific compiler versions. Of course, one could use inline assembly code, which gives you full control about which machine instruction is executed. However, a solution that implements run-time configurable communication speed using this technique sounds like a serious challenge to me.

A second problem is that interrupts, e.g., the millis interrupt, can confuse the timing when receiving a byte. The SoftwareSerial class uses the pin change interrupt to detect the falling edge of the start bit. If the millis interrupt is raised just before the start bit comes in, then the receiving interrupt routine could in the worst case start 6.7 µs too late. For slower bit rates, this might be tolerable. However, for 125 kbps the bit time is 8 µs, and so it is possible to miss a bit.

The AltSoftSerial library, which I had a look at in a previous blog post, uses a feature called input capture. This supports timestamping certain events, such as a falling edge. The value of a timer at this point in time is stored in the input capture register (ICR) and optionally an interrupt is raised. With that feature, one always gets the precise time when the start bit started, even if another interrupt was serviced at that time. If one also records the times of the edges following the start bit, one can easily reconstruct a transmitted byte.

Actually, one needs also a timer that tells you when the byte ends. This can be accomplished by using the output compare match feature. It is the dual to the input capture feature. Here one writes a value into the output compare register (OCR) and if the timer matches the value, some preconfigured action such as changing the level of an output pin or raising an interrupt is triggered. By setting the value such that after 8.5 bit times such an interrupt is raised, one can take all the information gathered by recording the times of rising and falling edges and return the received byte.

## Speeding it up

The problem with the AltSoftSerial library is that for each edge in a transmitted byte an interrupt is raised and a lot of work has to be done at the end of a transmitted byte. This is not sustainable at high bit rates., i.e., 115200 bps and higher.

In order to address this issue, I stuffed all the things described above in one interrupt routine. This worked so-so, but not really reliably. In order to get to the bottom of it, I used (once again) my Saleae logic analyzer. And without it, I probably would have had a hard time to understand the problems.

Here is the setup, showing the logic analyzer, the FTDI board which sends bytes at varying communication speeds, and the Arduino Uno running the new library. By the way: I used the same Arduino sketches and Python scripts to test my library as when I evaluated different serial libraries.

I inserted some code to generate short blips at critical parts in the ISR. With that, I was able to notice two problems. The interrupt service routine needed too much time starting up, and it needed too much time to finish the ISR.

First, the time between the falling edge of the start bit and the time when the ICR was saved was quite long, as can be seen in the next picture, which shows what is happening at 125 kbps.

In the second row, one sees two blips. The first one signals the point in time when the ICR was saved, the second one when everything is set up to record the incoming byte. It takes 2.7 µs to come to the point when the ISR stored the ICR and reconfigured the input capture to record rising edges. A large chunk of this time is dedicated to pushing registers on the stack. All in all, 15 registers are saved, which takes up roughly 2 µs. In addition, it takes (worst case) 10 cycles to process the interrupt and the noise cancellation takes another 4 cycles, which together is almost 1 µs.

If a millis interrupt is raised just before the falling edge of the start bit, this may then result in missing an edge and therefore a bit, i.e., one gets a read error.

I was able to reduce the startup time by declaring the ISR to be “naked” and then saving and restoring the registers using inline assembly code. Fortunately, it is known which registers one has to save. This allowed me to save the ICR early before all the registers were pushed on the stack. The result of all that is shown in the next picture (again at 125 kbps).

As one can see, the startup time has been reduced to 1.75 µs (marker P0). The second blip is still relatively late. But this event is constrained to happen before the midpoint of the first data bit, which is easily achievable, even if a millis interrupt slows the ISR down.

In the third row, the finishing period of the ISR is timed. The first blip signals the point when the byte has been read, and the second blip marks the point just before the ISR executes a “return from interrupt”. As one can see (marker P1), this goes into the stop bit quite a lot, leaving not much time for the user program to process the byte.

The way to deal with this problem is to reduce the amount of post-processing and to reduce the number of registers to be restored in the end. I addressed the issue by rewriting everything using inline assembly coding and employing the output compare match feature for locating the middle of the bit times as the sample points. This allowed me to reduce the number of register to 5 (down from 15). In addition, I reduced the post-processing of the received byte to storing it into the buffer and then restoring the registers.

As can be seen (marker P0), it now takes just under 1 µs to finalize the ISR. So at 125 kbps, the ISR returns 2.5 µs before the last data bit is finished, adding 5 µs to the time the user program can process the received byte–compared to the previous version.

The ICR is now saved after 1.3 µs and the question might be whether this is short enough to guarantee that the next edge (the one of the first data byte) does not clobber the ICR. As mentioned, the millis interrupt can take 6.7 µs in the worst case. These two times add up to 8.0 µs, which is just one bit time. For this reason, a more detailed analysis is necessary, taking into account all worst case assumptions, but eliminating any artifacts introduced by measuring.

In the worst case, the millis interrupt uses 106 cycles. We have to add 4 cycles of an instruction that might be executed between the millis ISR and our ISR, then 7 cycles for processing the interrupt and jumping to the start address, and finally 4 cycles for pushing one register and reading the low byte of the ICR. Once we have read the low byte, the high byte is saved in a temp register. The 4 cycles delay for recognizing an edge due to noise cancellation can be ignored because this delay applies to all edges. Also, the 2 cycles that are necessary to produce the blip can be ignored. This adds up to 106+4+7+4 = 121 cycles, which is 7 less than 128. In other words, we can easily cope with a serial bit stream that is 5% faster.

So, what about the other red blips? The second blip signals the time point when the output compare match register has been set up, which needs to happen before the middle of the first data byte. As can be seen from the measurement P2, there is enough time left. The third red blip is the time point when we are ready to sample the first bit. This should happen before the first bit has finished. Assuming that 75% of the bit time are usable, one should do it 12.5% before the end. As is obvious (markers P3), even when it is 30% before the end, timing is not critical.

Having said all this, with 121 cycles we are very close to the limit and if the implementation of the millis interrupt or the code generation of the compiler changes, then one might be in trouble. So for guaranteed 100% error-free communication (even in the future), I would disable the millis interrupt when using the library at 125 kbps.

Let us finally have a look at what happens at 250 kbps when a timer interrupt is raised.

Markers P0 shows that the communication ISR is delayed (most probably by the millis interrupt). Instead of saving the ICR 1.4 µs after the falling edge of the start bit, it takes 3.7 µs before this happens. No harm done though because the critical time point is 4µs after the falling edge. However, setting up the OCR happens 400 ns too late (markers P1). There are no yellow blips in the fourth row, which mark the sample points. And consequently, no bytes are recognized/received.

## Empirical results

I stress tested the new library similarly as I tested the other software and hardware UARTs. The results are shown in the next table. In summary, it looks as if one can use the library up to 125 kbps even with the millis interrupt enabled. The library can even cope with 250 kbps–the millis interrupt has to be disabled in this case, though.

BitrateTX speed
deviation
RX speed deviation
1200-0.1%-5.9%+5.4%
2400-0.1%-5.8%+5.4%
4800-0.1%-6.0%+5.2%
9600-0.1%-5.8%+5.3%
19200-0.1%-5.7%+5.3%
38400-0.1%-5.7%+4.9%
57600-0.2%-5.3%+5.1%
115200-0.2%-5.3%+4.8%
230400+0.6%-4.2%+5.3%#
7812-0.1%-5.8%+5.2%
15625-0.1%-5.7%+5.2%
31250-0.1%-5.6%+5.1%
62500-0.1%-5.3%+4.9%
125000-0.1%-5.2%+4.9%
250000-0.1%-4.8%+3.5%#
500000-0.1%________
1M-15.9%________
Transmit speed deviation and possible speed deviations when receiving data
('#' = no millis interrupt, '*' = 2 stop bits)

## Summary

The new SingleWireSerial library works very reliably and robustly up to 250 kbps. It implements a serial interface over a single wire, but it can also be used in a two-wire setting. So, I will probably use it in the future in all contexts I had used SoftwareSerial before, provided the respective pins are available. And I definitely plan to employ it in my next trial to implement a debugWIRE debugger.


text:
# Processing layered SVGs

February 15, 2020 at 9:54 PM by Dr. Drang

Over the past few months, I’ve been creating and processing a lot of SVG files . Initially, the processing was mostly manual, via cutting, pasting, finding, and replacing in BBEdit. But I’ve gradually learned how to use Python’s XML modules to automate the processing, which has both sped up my work and increased its accuracy.

Most of my work has started with me tracing over the areas of interest in plan view drawings so I can calculate distances and areas. The drawings usually come to me as bitmapped imageslike this one of the US Capitol, which I downloaded from Wikipedia .

Let’s say I want to get the area of this floor. I start by importing the file into a vector graphics program like Graphic , OmniGraffle , or Affinity Designer . Then I make layers above the bitmap and draw in the outer boundary, the holes or cutouts in the floor, and some length or feature that I can use to scale the drawing. Here’s what it looks like in Graphic on the iPad.

You can see the layers to the right of the image. The drawing layer is for the bitmap, the outline layer is for the outer boundary in blue; the cutouts layer is for the open areas of the Rotunda, the House and Senate chambers, the old Senate chambers, and Statuary Hall outlined in red; and the scale layer is for the green box drawn over the 64-foot scale just below the title.

I’ve made this graphic higher in resolution than I normally do for images here so you can zoom in to see the structure if you like. If you do, you’ll notice that the curved areas of the cutouts are approximated by a series of straight lines. I could have used Bezier curves for those portions, but straight lines work better with the Shapely library , which is what I’m going to use to calculate the area (in the next blog post; this one is going to concentrate on processing the SVG, which I’m about to get to).

So now I have a document in Graphic’s native format, which doesn’t do me much good. What I need to do next is export it as an SVG file, which, conveniently, Graphic can do on both the Mac and iPad. What comes out is a very large text file that looks like this:

xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
viewBox="0, 0, 2000, 1500">
<g id="Background">
<rect x="0" y="0" width="2000" height="1500" fill="#FFFFFF"/>
</g>
<defs>
<clipPath id="Clip_1">
<path d="M80.5,144.5 L1919.5,144.5 L1919.5,1355.5 L80.5,1355.5 z"/>
</clipPath>
</defs>
<g id="drawing">
<image

[lots and lots of base64 snipped out]

ECBAgAABAgQIECBAgAABAgQIENhd4P8DXwQCGxoPV+EAAAAASUVORK5CYII="
opacity="1" x="80.5" y="144.5" width="1839" height="1211"
preserveAspectRatio="xMidYMid" clip-path="url(#Clip_1)"/>
</g>
<g id="outline">
<path d="M123.599,412.613 L446.663,412.9 L452.08,664.029 L578.999,662.481
L579.773,552.975 L796.461,552.575 L797.666,380.968 L1200.281,379.81
L1199.042,551.939 L1420.726,551.234 L1422.843,657.932 L1547.177,658.461
L1547.066,407.545 L1876.229,404.746 L1872.399,972.508 L1548.302,975.134
L1547.528,831.19 L1419.062,831.19 L1419.448,910.514 L1195.406,911.675
L1195.793,895.036 L803.041,895.423 L803.815,912.836 L579.367,914.412
L577.414,836.858 L453.829,837.974 L452.992,978.854 L124.207,981.041
L123.599,412.613 z" fill-opacity="0" stroke="#0000FF" stroke-width="12"
stroke-opacity="0.518" id="Shape"/>
</g>
<g id="cutouts">
<path d="M173.197,526.183 L401.5,526 L404.38,869.031 L175.5,870.5 z"
fill-opacity="0" stroke="#FF0000" stroke-width="12"/>
<path d="M677.405,581.473 L701.206,587.925 L724.173,600.382 L743.054,615.953
L759.793,635.807 L769.33,658.19 L775.753,680.185 L776.142,709.575
L769.33,733.516 L760.377,755.121 L743.248,776.532 L725.536,791.714
L702.374,803.976 L679.406,809.815 L654.687,810.594 L654.687,789.962
L614.591,789.962 L614.172,600.618 L650.926,600.486 L650.753,581.647
L677.405,581.473 z" fill-opacity="0" stroke="#FF0000" stroke-width="12"/>
<path d="M1005.316,580.723 L1024.764,584.138 L1043.23,589.835 L1059.928,598.479
L1075.054,608.89 L1087.037,621.659 L1096.663,633.249 L1103.342,648.965
L1110.218,663.305 L1112.182,677.449 L1113.164,694.933 L1113.361,709.273
L1110.807,723.221 L1103.735,741.294 L1094.699,757.992 L1084.483,773.118
L1070.339,784.905 L1057.767,794.138 L1043.426,801.603 L1027.121,807.692
L1012.192,810.594L998.244,810.594 L983.314,808.675 L966.813,804.942
L949.919,797.87 L934.399,789.227 L918.684,774.886 L908.862,761.921
L898.646,747.384 L891.574,732.847 L889.021,717.721 L886.86,703.969
L886.467,692.969 L887.449,678.628 L892.557,661.537 L899.039,641.696
L907.29,628.927 L919.666,614.587 L933.614,602.211 L947.168,593.764
L961.705,586.692 L976.832,582.763 L987.44,580.723 L1005.316,580.723 z"
fill-opacity="0" stroke="#FF0000" stroke-width="12"/>
<path d="M1221.709,806.373 L1222.147,790.763 L1225.794,776.028 L1232.213,760.419
L1240.383,747.581 L1250.157,735.91 L1263.141,726.865 L1276.416,719.716
L1289.108,715.923 L1302.238,713.443 L1313.471,712.568 L1325.58,713.881
L1337.396,716.507 L1348.338,720.592 L1360.009,725.114 L1371.242,732.846
L1379.703,741.453 L1386.852,750.644 L1393.271,761.44 L1398.814,773.111
L1401.44,784.781 L1402.316,792.805 L1403.483,805.643 L1377.223,805.497
L1375.473,831.757 L1246.51,830.444 L1245.926,806.518 L1221.709,806.373 z"
fill-opacity="0" stroke="#FF0000" stroke-width="12"/>
<path d="M1611.074,553.144 L1814.482,549.597 L1811.978,833.534 L1611.32,831.757
L1611.074,553.144 z" fill-opacity="0" stroke="#FF0000" stroke-width="12"/>
</g>
<g id="scale">
<path d="M927.108,1295.893 L1081.541,1295.893 L1081.541,1313.799 L927.108,1313.799 z"
fill="#008100" fill-opacity="0.588"/>
</g>
</svg>

I’ve redacted most of the data associated with the bitmapped drawing, and I’ve added hard line breaks to make it easier to read. In the original, for example, each of the <path> elements is just one long line.

As you can see, each of the layers is inside a <g> element, and the id attribute is the layer’s name. The individual boundaries are <path> elements, and the coordinates of their vertices are inside the d attribute.

If you’ve ever programmed in PostScript or similar graphical languages, the d attributes might look familiar. The M is equivalent to PostScript’s moveto command, the L is like lineto , and the Z is like closepath .

To prepare for analysis by the Shapely library, I want to pull out all the vertex coordinates and write them out into CSV files. There will be a CSV file for each of the boundaries, and each line of a CSV file will be the x, y coordinates of a vertex. Here’s the code that does it:

python:
1:  import xml.etree.ElementTree as et
2:  import re
3:
4:  def path2csv(path):
5:    '''Transform an SVG path into vertex coordinates for a CSV file.
6:
7:    The path must consist of only moveto (M) and lineto (L)
8:    commands with an optional closepath (Z) at the end.'''
9:
10:    pstr = path.get('d')
11:    # Delete the starting moveto command
12:    pstr = re.sub(r'^M *', '', pstr)
13:    # Delete the closepath command
14:    pstr = re.sub(r' *[zZ]\$', '', pstr)
15:    # Put all the vertex points on separate lines
16:    pstr = re.sub(r' *L *', '\n', pstr)
17:    # Separate the x and y coordinates with a comma only
18:    pstr = re.sub(r' +, +| +,|, +| +', ',', pstr)
19:    # Return the multiline string of comma-separated coordinates
20:    return pstr
21:
22:  # Parse the SVG file and get the root
23:  tree = et.parse('capitol.svg')
24:  svg = tree.getroot()
25:
26:  # Handle the outline layer
27:  layer = svg.find('.//{http://www.w3.org/2000/svg}g[@id="outline"]')
28:  opath = layer.find('.//{http://www.w3.org/2000/svg}path')
29:  f = open('outline.csv', 'w')
30:  f.write('x,y\n')
31:  f.write(path2csv(opath))
32:  f.close()
33:
34:  # Handle the cutouts layer
35:  layer = svg.find('.//{http://www.w3.org/2000/svg}g[@id="cutouts"]')
36:  cpaths = layer.findall('.//{http://www.w3.org/2000/svg}path')
37:  for i, p in enumerate(cpaths):
38:    f = open(f'cutout-{i+1:02}.csv', 'w')
39:    f.write('x,y\n')
40:    f.write(path2csv(p))
41:    f.close()
42:
43:  # Handle the scale layer
44:  layer = svg.find('.//{http://www.w3.org/2000/svg}g[@id="scale"]')
45:  spath = layer.find('.//{http://www.w3.org/2000/svg}path')
46:  f = open('scale.csv', 'w')
47:  f.write('x,y\n')
48:  f.write(path2csv(spath))
49:  f.close()

The module we’ll use for parsing and traversing the SVG is xml.etree.ElementTree , imported as et on Line 1. This treats the SVG as a tree structure, with the elements of the document acting as nodes. Lines 23 and 24 read in the SVG file and parse it, leaving us with the root element of the tree saved in the svg variable. We can now traverse down the tree from svg to find the data we’re looking for.

The next three sections of the script deal with each layer of drawing—apart from the bitmap layer—in turn. Starting with the outline layer, we

1. Find the first (and only) <g> element in the tree that has an id attribute of outline . We’re using XPath syntax to define the query passed to the find command. The query starts at the current node ( . ) and searches at all levels below it ( // ) for a g node with the desired id ( [@id="outline"] ). The URL in curly braces is the XML namespace that defines the structure of an SVG. You can see it as one of the xmlns attributes of the <svg> root node.
2. Once we have the outline layer, we search it to find the first (and only) path . The XPath syntax is similar to what we used to find the outline layer.
3. We then create a CSV file and write the path’s d data to it. The data is formatted through the path2csv function defined on Lines 4—20.

These three steps are then repeated to handle the cutouts and scale layers. The only difference is that cutouts has more than one <path> , so we have to use findall instead of find and then loop through all the paths.I suppose I should have refactored these stanzas into a single function that gets called repeatedly.

I skipped over the path2csv function because I think it’s pretty easy to follow. Basically, it pulls out the d string from the supplied path and applies a series of regular expression substitutions to make a series of text lines with comma-separated coordinates. The trickiest part is that the syntax for d can vary a bit with regard to spaces and commas. I’ve tried to cover the variations I know about and end up with a consistent CSV format. The outline.csv file, for example, looks like this:

x,y
123.599,412.613
446.663,412.9
452.08,664.029
578.999,662.481
579.773,552.975
796.461,552.575
797.666,380.968
1200.281,379.81
1199.042,551.939
1420.726,551.234
1422.843,657.932
1547.177,658.461
1547.066,407.545
1876.229,404.746
1872.399,972.508
1548.302,975.134
1547.528,831.19
1419.062,831.19
1419.448,910.514
1195.406,911.675
1195.793,895.036
803.041,895.423
803.815,912.836
579.367,914.412
577.414,836.858
453.829,837.974
452.992,978.854
124.207,981.041
123.599,412.613

OK, so now we have a series of CSV files with the boundary coordinates given in pixels (or points, depending on which graphics software was used to create the SVG). The next step is to use the Pandas and Shapely libraries to do the analysis. That’ll be next time.

format: plain


text:
# Maplesoft Blogger Profile: Samir Khan

Technical professional in industry or government

My role is to help customers better exploit our tools. I’ve worked in selling, supporting and marketing maths and simulation software for all my professional career.

I’m fascinated by the full breadth and range of application of Maple. From financial mathematics and engineering to probability and calculus, I’m always impressed by what our users do with our tools.

However much I strenuously deny it, I’m a geek at heart. My first encounter with Maple was as an undergraduate when I used it to symbolically solve the differential equations that described the heat transfer in a series of stirred tanks. My colleagues brute-forced the problem with a numerical solution in Fortran (but they got the marks because that was the point of the course). I’ve since dramatized the process in a worksheet, and never fail to bore people with the story behind it.

I was born, raised and spent my formative years in England’s second city, Birmingham. I graduated with a degree in Chemical Engineering from The University of Nottingham, and after completing a PhD in Fluid Dynamics at Herriot-Watt University in Edinburgh, I started working for Adept Scientific – Maplesoft’s partner in the UK.

## Posts by Samir Khan

### Modelling Flow Inertia in Three Coupled...

August 30 2012 by Maple MapleSim

5

3

1 Introduction

Three tanks are connected with two pipes. Each tank is initially filled to a different level. A valve in each pipe opens, and the liquid levels gradually reach equilibrium. Here, we model the system in MapleSim (including the influence of flow inertia), and also derive and solve the analytical equations in Maple.

### Modeling Water Hammer in MapleSim

Liquid flowing in a pipeline has inertia.  If a valve at the end of the pipeline suddenly closes, a pressure surge hits the valve, and travels through the pipeline at the speed of sound. The damping effect of fluid friction gradually attenuates the pressure wave.

This phenomenon is called water hammer and can cause damage significant damage, sometimes even rupturing the pipeline.

The pressure wave often produces audible sound. If you’ve ever heard...

### Pendulum Waves

I recently stumbled upon a hypnotic video of 15 out-of-phase pendulums from a physics experiment at Harvard University.

The...

### Modeling a Double Pipe Heat Exchanger...

December 29 2010 by Maple MapleSim

6

3

A prospective customer recently asked if we had a MapleSim model of a double pipe heat exchanger. Heat exchangers are a critical unit operation in the process industries, and accurate models are needed for process control studies.  I couldn't find an appropriate model so I decided to derive the dynamic equations, and implement them using MapleSim's custom component interface.  I'll outline my modeling strategy in this blog post.

### Foreign Exchange

October 01 2010 by Maple

I lived in the UK before making the barely-considered decision to move to Canada.  I still have savings denominated in pounds sterling (all dutifully declared on my Canadian tax return).  Accordingly, I keep a close watch on the GBP-CAD exchange rate so I have some sense of my net worth.

When I arrived in Canada in July 2008, one pound sterling bought $2, down from$2.30 two years before that.  Today, the pound has devalued further and is worth around...

### The Traveling Salesman's U.S. Roadtrip

June 04 2010 by Maple 14

6

4

I spend much of my time traveling for business. These trips often last a week, and we try to visit as many potential customers as possible, and in the most efficient order. This involves matching our hosts' calendars with our own, booking the most cost effective travel options, and coping with last-minute cancellations and changes. It isn’t easy!

This has become so much easier with the advent of shareable calendars and mapping services, like Google Maps. ...

### Making the obvious…well…obvious

May 04 2010 by

2

1

Sometimes the obvious escapes me, and it’s only due to some chance observation that I realize the same fundamental principles are everywhere.

A short time ago, I created a simple hydraulic network in MapleSim, and after experimenting with some of the parameters, found it gave the same behaviour as an electric circuit I’d modeled earlier.

### Getting Things Done

January 20 2010 by

1

0

Around the time that Windows 98 was at its most popular, I used to dabble in programming Windows user interfaces with Visual C++ and the help of several thick MFC (Microsoft Foundation Class) manuals.  I wanted to create packaged (and admittedly simple) engineering applications. But for a chemical engineer with little background in Windows programming, combining math functionality with a user interface was time-consuming and cumbersome. (MFC can be arcane unless you’ve invested considerable time in learning the API.)

Later, I migrated to VB6.  Designing an interface was an order of magnitude easier, but I still had to roll many of my own math routines, or link to external libraries. While I may be interested in the mathematical mechanics of adaptive step sizing in Runge-Kutta algorithms at the intellectual level, it was secondary to my then goal.

### The Diet Problem

December 17 2009 by

1

0

If you were to stroll into the Application Engineering office at Maplesoft, you might be led to believe that we subsist on nothing but donuts, pizza, chocolate and coffee.  It’s even worse at this time of year when we have many more opportunities to over-consume. I try to have a balanced diet, but there are too many temptations scattered around the office (including candy at the office entrance – our receptionist, Walli, expects me at 3pm each day without fail). It doesn’t help that a virtually limitless supply of donuts are only a three minute drive away.

### The Secret Life of a Reseller

December 08 2009 by

1

0

Resellers buy products from a manufacturer, and sell to consumers.  They are an important factor in many industries, including the one in which I work.  Maplesoft operates through a network of resellers throughout the world (apart from North America and a few other territories).  Some may suspect I’m somewhat biased in promoting the importance of resellers; I spent seven years working for Adept Scientific, Maplesoft’s partner in the UK.

The largest resellers are based in larger, better developed markets with a strong manufacturing and research base (like Cybernet and Scientific Computers in Japan and Germany).  Conversely, many smaller resellers, like Multi-On and Czech Software First in Mexico and the Czech Republic, operate in markets with significant growth potential.

### Multi-threading – or How I Learned to...

November 17 2009 by

2

5

Dual- and quad-core PCs are now ubiquitous.  While making your operating system a better multi-tasking environment, they’ve had a limited effect on the code that most technical professionals write.  This is largely because of the perceived difficulty of parallel programming.   The evolution , however, of high-level languages that support multi-threading throughout the 90s and beyond, removed the need to manage threads at the low level, allowing engineers to concentrate on what part of the algorithm could be run in parallel.  Given the ever-increasing complexity of systems that have to be simulated, multi-threaded programming can offer significant time savings for many the problems that can be easily parallelized (and for which time-savings of parallelization outweigh the overhead).

### Training Day

November 05 2009 by

0

1

The first professional training course I gave involved a 275 mile late evening drive in a 1 litre European econobox from Letchworth in the UK to a dingy hotel in Alnwick.  I was pretty nervous –some of my delegates were engineers who had been using Mathcad for over ten years, and I was being paid to tell them what they didn’t know.  The following day, after drinking several litres of coffee, I drove another five miles to the training location, only to find that just one delegate had turned up.  Luckily he was just an intern who’d never used Mathcad before – and to him I was an expert.

### An Avalanche of Data

October 14 2009 by

1

1

The evolution of written language started in earnest in 3500 BC with Cuneiform, spurring a step-change in the volume of information that could be recorded and transmitted over large distances.

This evolved into wide spectrum of other methods of information transmission. The first transatlantic telegraph cables, for example, were laid in the mid-to-late nineteenth century by information pioneers – industrialists who saw the vast benefit in increasing the rate of information exchange by many orders of magnitude. This led to a Cambrian explosion in the sheer volume of information transmitted internationally, increasing trade and commerce to hitherto unseen levels.

### So a door slammed shut on me...

May 11 2009 by

1

0

A few mornings ago, I drove to the office, bleary-eyed and still waiting for my first liter of coffee to kick in.  I parked, exited my car, and started walking to the entrance.  Someone a few meters ahead of me held the door open, but let go while I was still about a meter away.  Judging the closing speed of the door, I thought I had enough time to sneak in.  However, during the latter stages of its closing sweep, it suddenly sped up, and slammed shut. Not yet being suitably caffeinated, I uttered a small curse, damning the door and all its close mechanical relatives, and reached for my key fob.

### It’s a Numbers Game

April 08 2009 by

1

0

When I was a toddler and learning about the concept of numbers, I used to play a simple game with my parents.  They’d think of a number, and I’d try to guess it.  They would shout “hotter!” if I were getting closer to the number and “colder!” if I was getting further away.  I’m still fascinated by number games, but now it’s Sudoku, the Countdown numbers game… or balancing my bank account at the end of the month.

### The Remarkable Story Behind the Mandelbrot...

April 02 2009 by

While visiting a cathedral in Germany, Bob Schipke, a retired Harvard mathematician was astounded to find a glyph in a 13th century manuscript that looked remarkably like the Mandelbrot set.  This led to a remarkable voyage of discovery that was publicised in a

### Was Shakespeare a Drummer?

March 06 2009 by

0

2

Great playwrights and poets are drummers – they craft the written word so that the rhythm and the cadence of their dialogue when spoken are a drumbeat, and combine with the meaning of the language to create emotion.  Shakespeare, for example, used syllables as his drumbeats (as did many other playwrights and poets).  Analyzing linguistic structure isn’t a common application for a math tool (and for a very good reason), but can Maple tell us more about Shakespeare’s favourite drumbeat?

### Am I Making Sense?

February 23 2009 by

1

0

I'm one of several technical writers at Maplesoft.  It's our job to craft the text in our brochures and user stories, and on our web site.  We all have differing styles, but we share a common goal; we want to write in a manner that’s technically compelling but simple to understand.

After recently exploring Maple’s string manipulation tools, I was surprised to find a command that measures the readability of a sample of English text.  It seems that as well as making you a better mathematician, Maple will poke and prod you into being a better writer.

### Stringing me Along

January 15 2009 by

0

0

I was recently forwarded a link to this Snopes article.

According to the urban legend described therein, text is still readable if all the letters in a word apart from the first and last are randomized. I quickly threw together a Maple worksheet, primarily using its flexible string manipulation tools.

### Let’s Get Physical

January 09 2009 by

0

0

We’re now at an inflection point in which symbolic technology will automate physical modeling and equation generation through tools like MapleSim. As a recent webinar hosted by Maplesoft and the Society of Automotive Engineers proved, engineers are fascinated by the application of the technology, and the technology itself.

### Taking Stock with Benford

January 07 2009 by

1

0

• Voting patterns in Mexico and Florida.
• The size of files in your Maple 12 installation
• Stock trading volumes on the NYSE

What do all of these have in common? They, and other data sets drawn from the real world, often follow a non-intuitive pattern called Benford’s Law.

### Good Vibrations

December 04 2008 by MapleSim 1

0

2

Over the last few years, I’ve been lucky enough to spend time in Taiwan.  In my first visit to Taipei, I was astounded by the sheer scale of the Taipei 101 skyscraper.  At over 500m tall it dwarfed everything else in the skyline.

Given the proximity of many active fault lines, tall buildings in Taipei have a degree of earthquake protection engineered into them with a tuned mass damper .

### An Animated Discussion about Pendulums

0

2

I was in Boston last week attending the ASME International Mechanical Engineering conference demonstrating MapleSim, our new tool for physical modeling.  I had the opportunity to speak to a large number of delegates, but I remember one conversation in particular; a professor who taught freshman students was bemoaning the fact that he found it harder and harder to impress students with his relatively simple animations of physics phenomena.  A simple animated pendulum no longer captivated students who were already immersed in the interactive physics-enabled environments of video games.  He had to escalate the intricacy of his demonstrations, but generating them was starting to consume too much of his time.

### Mandelbrot Mania with Maple

November 03 2008 by

1

1

Twenty years after I first plotted the Mandelbrot set on a ZX Spectrum with 48K of RAM and a 3.5MHz processor, I’m still amazed by the sheer complexity and beauty contained therein.  I now have access to far more computing horsepower and can create ever more vivid visualizations.  It’s surprising what you can do with some creativity and a modicum of patience.

### A Better Tomorrow in Engineering Softwar...

September 24 2008 by

0

0

Like most students studying engineering in the 90s, spreadsheets were the de facto calculation tool.  I used them for everything from food budgeting to pump and piping sizing calculations.

Computing power has since exploded, and engineers have far better choices.  But engineers still continue using spreadsheets.

Why?

There’s really only one reason – ubiquity and familiarity.  A spreadsheet is installed on nearly all desktop computers, but even though most engineers are aware of at least some of their design deficiencies they keep on using them.

### Past Returns are not an Indication of...

September 11 2008 by

1

2

That’s a mantra I need to have drummed into me, and perhaps tattooed on the inside of my car so I’m reminded every morning.  But I keep on making the same mistakes.

I seem to think that if I’ve “optimized” my portfolio with a few flashy calculations that I’ve done my due diligence, and the next stop is financial independence.  It’s the black box syndrome – trusting the output of a computer program without truly understanding the real issues.  Most portfolio analyses, for example, hinge on historical data, which of course doesn’t predict the sub-prime blow-up in the US or whether Brazilian coffee growers are on strike.  They’re all backward looking.

 Page 1 of 1


text:
# Inverse Cotangent Calculator

Calculate Inverse Cotangent of the Number
Enter a Number =

In Degrees

Inverse Cotangent Calculator is a free online tool that displays the inverse cotangent value in both degree and radian measure for the given input. CoolGyan online inverse cotangent calculator tool makes the calculation faster, and it displays the inverse cotangent value in a fraction of seconds.

## How to Use the Inverse Cotangent Calculator?

The procedure to use the inverse cotangent calculator is as follows:

Step 1: Enter the number in the input field

Step 2: Now click the button ”Calculate Inverse Cotangent” to get the result

Step 3: Finally, the inverse cotangent value for the given number will be displayed in the output field

### What is Meant by Inverse Cotangent?

In trigonometry, the trigonometric functions are obtained from the ratios of the sides of a right-angle triangle. The six important trigonometric ratios are sine, cosine, tangent, cosecant, secant and cotangent. The inverse of these functions is called the inverse trigonometric function. The inverse of the cotangent function is called inverse cotangent or arccot. It is denoted by cot -1 x. The domain and range of arccot function is -âˆž < x < âˆž, and 0 < y < Ï€ respectively.


text:
Find the equation of the right bisector of the line segment joining the points (3, 4) and (–1, 2).

Asked by Abhisek | 1 year ago |  112

##### Solution :-

The right bisector of a line segment bisects the line segment at 90°.

End-points of the line segment AB are given as A (3, 4) and B (–1, 2).

Let mid-point of AB be (x, y)

x = $$\dfrac{3-1}{2}$$$$\dfrac{2}{2}$$ = 1

y = $$\dfrac{4+2}{2}$$$$\dfrac{6}{2}$$ = 3

(x, y) = (1, 3)

Let the slope of line AB be m1

m1 = $$\dfrac{2-4}{-1-3}$$

$$\dfrac{-2}{-4}$$

$$\dfrac{1}{2}$$

And let the slope of the line perpendicular to AB be m2

m2 =$$\dfrac{-1}{\dfrac{1}{2}}$$

= -2

The equation of the line passing through (1, 3) and having a slope of –2 is

(y – 3) = -2 (x – 1)

y – 3 = – 2x + 2

2x + y = 5

The required equation of the line is 2x + y = 5

Answered by Pragya Singh | 1 year ago

### Related Questions

#### Find the angle between the line joining the points (2, 0), (0, 3) and the line x + y = 1.

Find the angle between the line joining the points (2, 0), (0, 3) and the line x + y = 1.

#### Prove that the points (2, -1), (0, 2), (2, 3) and (4, 0) are the coordinates of the vertices

Prove that the points (2, -1), (0, 2), (2, 3) and (4, 0) are the coordinates of the vertices of a parallelogram and find the angle between its diagonals.

#### Find the acute angle between the lines 2x – y + 3 = 0 and x + y + 2 = 0.

Find the acute angle between the lines 2x – y + 3 = 0 and x + y + 2 = 0.


text:
# Analysis of Monopole Impedance

This example analyzes the impedance behavior of a monopole at varying mesh resolution/sizes and at a single frequency of operation. The resistance and reactance of the monopole are plotted and compared with the theoretical results. A relative convergence curve is established for the impedance.

### Choose Frequency of Operation and Calculate Wavelength

Choose the operating frequency for the monopole and calculate the wavelength in free space at the frequency.

f = 400e6;
speedOfLight = physconst('lightspeed');
lambda = speedOfLight /f;

### Select Physical Parameters of Monopole

The monopole is typically fed by a coaxial transmission line of characteristic impedance 50 ohm. Define the height of the monopole to be slightly less than quarter-wavelength [1], $h/\lambda =0.236$. The radius of the monopole also influences the impedance. Define the radius in terms of wavelength, $a/\lambda =0.001588$. The monopole model in the Antenna Toolbox ™ uses a metal strip. The width of the strip, w, is related to the radius, a, of an equivalent metal cylinder by $w=4a$ [2]. Choose a large ground plane by specifying the length and width of the ground plane to be twice the operating wavelength.

h_over_lambda = 0.236;
a_over_lambda = 0.001588;
h = h_over_lambda*lambda;
a = a_over_lambda*lambda;
w = cylinder2strip(a);
gpL = 2*lambda;
gpW = 2*lambda;

### Create and Modify Monopole

Create a monopole antenna and modify its properties to match the design parameters.

mp = monopole;
mp.Height = h;
mp.Width = w;
mp.GroundPlaneLength = gpL;
mp.GroundPlaneWidth  = gpW;
figure;
show(mp);

### Calculate Baseline Impedance

Calculate and store the impedance and the number of triangles in the mesh when using the default mesh size.

Zbaseline = impedance(mp,f);
meshdata  = mesh(mp);
Nbaseline = meshdata.NumTriangles;

### Meshing Parameter Variation

You can evaluate the accuracy of the results by changing resolution of a triangular surface mesh. The triangular surface mesh implies a discretization of the surface geometry into small planar triangles. All antenna surfaces in the Antenna Toolbox ™ are discretized into triangles. To specify the resolution of the mesh, provide the size of the maximum edge length, i.e. the longest side of a triangle among all triangles in the mesh, prior to analysis. Alternatively, define a range of values for the maximum edge length.

maxEdgeLength = gpL./(2:2:16);

### Set up Analysis Parameters

Create arrays to save impedance, relative change in impedance and the size of the mesh.

m = length(maxEdgeLength);
Zin = zeros(1,m);
numTri = zeros(1,m);
tolValue = .05.*ones(1,m);
tolCheck = nan*ones(1,m);
Ztemp = Zin(1);

### Calculate Impedance Variation

For each value of the maximum edge length, update the mesh, calculate the impedance at the operating frequency and the number of triangles in the mesh. Save the impedance and number of triangles in the mesh for the convergence analysis. Finally, calculate the relative change in the impedance between subsequent mesh refinement steps.

for i = 1:m
mesh(mp,'MaxEdgeLength',maxEdgeLength(i));
Zin(i) = impedance(mp,f);
meshdata = mesh(mp);
numTri(i) = meshdata.NumTriangles;
Zchange = abs((Zin(i)-Ztemp)/Zin(i));
Ztemp = Zin(i);
tolCheck(i) = Zchange;
end

### Impedance of Monopole on Finer Meshes

Plot the input impedance at the operating frequency for each mesh update. Observe that the baseline values of the resistance, ${R}_{in}$ and reactance, ${X}_{in}$ are (for the default mesh),

, .

The result published in [1] for the case $a/\lambda =.001588$, $l/\lambda =0.236$

is

${R}_{in}=36.82$ $\Omega$, ${X}_{in}=0$ $\Omega$

Our result matches the resistance and suggests that a weak inductive component is present as well. The circled values for resistance and reactance are the results obtained for the default baseline mesh. Note, that the results of [1] cited above are related to cylindrical monopoles; they take into account the effect of a gap between the inner conductor and the outer conductor of the coaxial transmission line. Our geometrical model approximates the cylindrical monopole with a rectangular strip and does not account for the gap in the groundplane.

figure;
plot(numTri,real(Zin),'*-','LineWidth',2)
hold on
plot(numTri,imag(Zin),'r*-','LineWidth',2)
hold on
plot(Nbaseline,real(Zbaseline),'o','MarkerSize',10)
plot(Nbaseline,imag(Zbaseline),'ro','MarkerSize',10)
axis([min(numTri),max(numTri),-10*abs(round(min(imag(Zin)))),...
1.5*floor(max(max(real(Zin),max(imag(Zin)))))])
grid on
xlabel('Number of triangles')
ylabel('Input Impedance Z_i_n - \Omega')
legend('R_i_n','X_i_n')
title('Monopole Impedance vs. No. of Triangles in Mesh')


text:
# Mapping the Zettelkasten on to a digital system

Hi I am relatively new to this subject and thought that it would be wise to debug my thinking before progressing too far. I am having difficulty with topics and connected zettels......

From what I have read the Luhmann system:
- Identifies zettels with a unique id, and
- On inserting a new zettel to an already existing topic, the zettel is allocated a unique id chained to that zettel 'string', or
- On inserting a new zettel for a new topic, the next top level id in the sequence is allocated;
- Each zettel is given one or two keywords, which are closely tailored to that individual zettel;
- If a zettel has connections to a zettel in another topic is directly references that topic.

If the above is mapped onto a digital zettelkasten, then:

• The unique id becomes, say YYYY-MM-DD-HHmm
• The link to an already existing topic is a wikilink
• The direct link to another zettel is a wikilink
• The keywords are tags

My question: assuming the above is correct, then what means within a digital zettelkasten is typically used to assign topics to the top level zettels? As keywords are tightly tailored and the top level topics must be broad by their nature, so using tags for both would be confusing.

Thanks for feedback

## Comments

• edited November 3

@Carriolan said:
Hi I am relatively new to this subject and thought that it would be wise to debug my thinking before progressing too far. I am having difficulty with topics and connected zettels......
My question: assuming the above is correct, then what means within a digital zettelkasten is typically used to assign topics to the top level zettels? As keywords are tightly tailored and the top level topics must be broad by their nature, so using tags for both would be confusing.

Thanks for feedback

Hi and welcome to the forum (if this is your first post)!

There are a number of ways that one could use to create “entry points” into your Zettelkasten. One is the good old index - a single note (zettel) that contains subjects in alphabetical order, but instead of page numbers one enters links to one or several relevant zettels. A related but different method is to use “structure notes”. Each structure note (itself a single zettel) could represent a very high level topic, for example, “Personal History” (one of mine). Then one might have on this Personal History structure note some sub-topics - continuing my example, “Early Memories”, “Primary School”, “High School”, “Early Married Life”, etc. And under each of the sub-topics, one could have a list of topics and links to related zettles, e.g., under “High School”, I might have the topics “Good friends”, “Favourite classes”, etc.

Structure notes impose a top down structure on your Zettelkasten but still allow you to use tags and connections between zettels to build a non-hierarchical / non-linear network - the best of both worlds.

Some people actually like to hang every zettel off at least one structure note. My own practise is to use structure notes for some topics (for which I have a lot of zettels) but not to insist every zettel be connected to a structure note. As an alternative, I use tags extensively and make sure my zettels are well-connected to other zettels.

Hope this makes sense and addresses your question.

You can search on “structure notes” within this forum - you will find people use them in many different ways, and from their comments, might find a particular usage that suits your workflow.

• edited November 4

Yes it was my first post..... Thanks.

@GeoEng51 said:
There are a number of ways that one could use to create “entry points” into your Zettelkasten. One is the good old index - a single note (zettel) that contains subjects in alphabetical order, but instead of page numbers one enters links to one or several relevant zettels. A related but different method is to use “structure notes”. Each structure note (itself a single zettel) could represent a very high level topic, for example, “Personal History” (one of mine).

For clarification:

• An Index note is a single note for the whole of the Zettelkasten which lists all the zettel topics together with links by topic, and
• A Structure note resides in the note hierarchy of a specific topic to give it 'Structure' and to enable more 'entry points'. Its links are restricted to other notes within that topic hierarchy and may be linked to other Structure notes within that same hierarchy.

My questions are:

• Is the Index note typically an index of the top level notes or is it an index of all 'entry points' i.e. top level notes and Structure notes?
• Can top level notes be Structure notes, (or is that being too top down)?
• @Carriolan said:
My question: assuming the above is correct, what means within a digital zettelkasten is typically used to assign topics to the top-level zettels? As keywords are tightly tailored and the top level topics must be broad by their nature, so using tags for both would be confusing.

tl;dr: You have a firm grasp of how topics are connected in a digital ZK.

How are 'top-level' zettel topics set? Other zettelnauts will have other ideas, but...

Create a structure note (top-level) when you have four or more (this is arbitrary) notes on a subject you imagine you'll explore producing more.

Some top-level notes are chronological lists of other notes. (It probably could be grouped with a tag, but I use a structure note in this case. In other cases, I use a tag. I can't say why.)

In some top-level notes, links are grouped in logical groups.

The best structure notes are the ones where the links are grouped together and annotated.

After sleep in your question, I think I missed. I'll try a different tack to answer from my experience, "what means within a digital zettelkasten is typically used to assign topics to the top level zettels?"

Sturcure notes appear organically. At first don't even think about them. After a while you'll notice a small group of notes that are relevant to each other in a particular way. As an example, I noticed a growing number of notes around the idea of PROCRASTINATION. Some related to its structure, the habit, its causes, how to prevent and constructively use it, etc. Making a structure note and the habit of hanging every new zettel on a structure note continues to elaborate my understanding of procrastination.

I think I still missed answering you question. Let me try again. What is the focus of your ZK? That might help with relevant examples. I want to admonish you resist pre-catagorizing your ZK with perconseives ideas about what you might use for structure notes and let things flow for a while. You'll be surprise when it becomes obvious where a structure note is called for. My core interests are philosophy, writing and coding. So these were the first candidates that poped up. When the coding structure not became unwheedly I refactored the python section into a structure note of its own.

Let me try again by showing the value of adding structure. THis doesn't happen immediately as it organically grows.

Here is part of a structure note followed by a screen shot of a full text search of "zettelkasten". You can see the disorganized mess in the second screen shot. In the zettelasten structure note the oldest link in Zettelkasten Legend [[201812071155]] and the newest is Creative Idea Compass [[202210160719]]. This structure note is almost 4 years old and is still being refactored.

Will Simpson
“Read Poetry, Listen to Good Music, and Get Exercise”
kestrelcreek.com

• Thank you @will for this detailed exposition, appreciated. Your repeated attempts to fully answer the question revealed elements that I needed, but didn't realise that I needed (not an unknowable unknown (-; ). If I were to savagely summarise your approach / advice, it would be: to get on with the business of generating zettels and let Structure notes be produced organically through the necessity of adding clarity to a cluster of thoughts (zettels).

Further from what I am reading, anything which encourages thought should be promoted. So on that basis annotated Structured notes must be the route. This bottom up approach seems to put the emphasis / effort in the areas which would yield the most benefit.

I have given some thought as to the size of cluster that would naturally give rise to a Structure note. From what I have read the maximum number of items that a human brain can cope with is no more than six or seven at once, so I guess that would be it.

• @Carriolan said:
If I were to savagely summarise your approach / advice, it would be: to get on with the business of generating zettels and let Structure notes be produced organically through the necessity of adding clarity to a cluster of thoughts (zettels).

Yes. In the early stages, one is best served by concentrating on capturing atomic ideas. More advanced techniques can be taken up as we advance. There is no need to hurry things.

Further from what I am reading, anything which encourages thought should be promoted. So on that basis annotated Structured notes must be the route. This bottom up approach seems to put the emphasis / effort in the areas which would yield the most benefit.

My first structure note came a little late - I'm slow and always road the short bus in primary school.
The following quote is from my post in the great relevant thread - Questions that arise after a month of ZettelKasten — Zettelkasten Forum

@Will said over on another post:
My first note was on 20181108, and my first structure note was on 20191126. It was 383 days until my first structure note. I had 553 notes before I had my first structure note. It seems a bit odd looking back on it. But I was not in any hurry. I let the idea of adding any structure to my zettelkasten evolve naturally unforced.

Back to your comment.

@Carriolan said:
I have given some thought as to the size of cluster that would naturally give rise to a Structure note. From what I have read the maximum number of items that a human brain can cope with is no more than six or seven at once, so I guess that would be it.

Research has updated the maximum number of items the brain can juggle at one time to 3-5. That is for young adults, not old geezers like us!
The Magical Mystery Four: How is Working Memory Capacity Limited, and Why? - PMC

Will Simpson
“Read Poetry, Listen to Good Music, and Get Exercise”
kestrelcreek.com

• @Will said:
Research has updated the maximum number of items the brain can juggle at one time to 3-5. That is for young adults, not old geezers like us!

My perceived horizons have now been reduced and are in line with my age - Thanks for your help in getting me started.

• edited November 5

There is hope:

Long Term Working Memory: https://pubmed.ncbi.nlm.nih.gov/7740089/

I am a Zettler

• @Carriolan I support @Will ’s explanation of structure notes and letting them “appear” organically, as your need for one becomes evident. My Zettelkasten doesn’t contain many structure notes, as I have previously not felt the need for them. More recently, I have been pulling information out of a series of old magazines and found it useful to have a structure note for each magazine. So - it can go either way - sometimes structure notes can come first, but mostly for me, their need manifests itself.

In regard to an index note - this is simply one note that lists all the main topics in your Zettelkasten, each line being linked to the most relevant zettels. Those links could be to structure notes or just to single zettels; I don’t think it matters.

• edited November 6

@Sascha said:
There is hope: Long Term Working Memory: https://pubmed.ncbi.nlm.nih.gov/7740089/

Thank you for this glimpse of hope. I am sure the reference in time will spawn a few zettels. However my immediate priority is to maintain my neuroplasticity.

Post edited by Carriolan on
• Thank you both (@GeoEng51 and @Will) for sorting me out. I am resolved to let organic 'bottom up' annotated Structure notes form of their own accord.

With regard to Index notes, in Obsidian I can easily generate a self-maintaining Index note using a Dataview query. So I am good to go (at least for now!) - Thanks.

Sign In or Register to comment.

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


text:
# Charles Law Formula

Filter Type:

## Listing Results Charles Law Formula lowest price

8 hours ago Later, Joseph Gay-Lussac, in 1802, modified and generalized the concept as Charles’s law. At very high temperatures and low pressures, gases obey Charleslaw. Derivation: CharlesLaw states that at constant pressure, the volume of a fixed mass of a dry gas …

Posted in: Charles law formula units

8 hours ago The above formula is Charles' Law, named after the French experimenter Jacques Charles (1746-1823). It states that the volume of a fixed mass of gas at a constant pressure is directly proportional to its absolute temperature. Stating this in plain English, when temperature increases, volume increases. When temperature decreases, volume decreases.

Posted in: Charles law formula for t2

Just Now Click here to use Charles Law Calculator to obtain immediate results based on Charles Law Equation. Charles law charles law formula charles

Posted in: Charles law formula explained

9 hours ago Charles' Law . On 5 June 1783, Joseph and Etienne Montgolfier used a fire to inflate a spherical balloon about 30 feet in diameter that traveled about a mile and one-half before it came back to earth. News of this remarkable achievement spread throughout France, and Jacques-Alexandre-Cesar Charles immediately tried to duplicate this performance.

Posted in: what is the charles law

1 hours ago Start studying Gases and Gas Laws. Learn vocabulary, terms, and more with flashcards, games, and other study tools.

Posted in: Charles law formula

9 hours ago Start studying Chapter 13: Gases. Learn vocabulary, terms, and more with flashcards, games, and other study tools.

Posted in: Study Law

4 hours ago Start studying Gas Laws. Learn vocabulary, terms, and more with flashcards, games, and other study tools.

Posted in: Study Law

7 hours ago Start studying Chemistry Ch. 13. Learn vocabulary, terms, and more with flashcards, games, and other study tools.

Posted in: Study Law

1 hours ago Boyle's Law. At a constant temperature for a fixed mass, the absolute pressure and volume of a gas are inversely proportional. Boyle's Law formula.

Posted in: Form Law

1 hours ago Gas Laws for Mr. Chun's chemistry class Learn with flashcards, games, and more — for free.

Posted in: Law Commons

6 hours ago Charles' Law is a special case of the ideal gas law.It states that the volume of a fixed mass of a gas is directly proportional to the temperature.This law applies to ideal gases held at a constant pressure, where only the volume and temperature are allowed to change.

Posted in: Form Law

1 hours ago review for test Learn with flashcards, games, and more — for free.

Posted in: Law Commons

4 hours ago What is Charleslaw formula? Uncategorized. The physical law that the volume of a fixed mass of gas held at a constant pressure varies directly with the absolute temperature. This law states that the volume of a given amount of gas ,at a constant pressure gas varies with …

Posted in: Form Law

7 hours ago

1. To verify Charles's law by studying volume versus temperature relationship. And also to determine the absolute zero temperature from the volume-temperature graph.

Posted in: Law Commons

3 hours ago In this video i get to explain what charles law is, and how the formula for charles law comes about.I would like to thank all of you that keep sending finan

Posted in: Form Law

1 hours ago low pressures low molar mass. Ideal Gas Assumptions-gas molecules move-molecules don't attract or repeal each others-molecules travel in a straight line.-collisions are elastic-faster the molecules move the more energy they have.

Posted in: Energy Law

4 hours ago Air behaves like the ideal gas and follows the laws: Boyle’s law (PV=C) and Charles’s law (V/T = C). Read here to know about the basics of compressing air and appreciate the reason for air compressor following polytropic or isentropic compression instead of isothermal or adiabatic one. The free air has some density or the given mass of gas occupies certain volume in free space.

Posted in: Form Law, Air Law

Just Now An experimental gas law is the Charles Law. The formula used is original volume/original temperature= new volume/new temperature. The law

Posted in: Form Law

8 hours ago Search for jobs related to Charles law formula or hire on the world's largest freelancing marketplace with 20m+ jobs. It's free to sign up and bid on jobs.

Posted in: Form Law, Employment Law

9 hours ago Chemical Laws, Concepts, and Principles. Explore the major theories, laws, and principles of chemistry and learn how to apply them. Science View More. Learn About Malleability and the Treatment of Metals. Review Gay-Lussac's Gas Law.

Posted in: Law Commons

1 hours ago The three gas laws, Boyle's Law, Charles' Law, and Gay-Lussac's Law, are combined to form the Combined Gas Law. Explore the combined gas laws, look at …

Posted in: Form Law

4 hours ago Example of the Law of One Price . If the price of any economic good or security is inconsistent in two different free markets after considering the effects of …

Posted in: Law Commons

3 hours ago Existing federal law authorizes, until September 30, 2019, a state to allow low emission and energy-efficient vehicles to use lanes designated for HOVs without regard to vehicle occupancy. Existing federal law also authorizes, until September 30, 2025, a state to allow alternative fuel vehicles and new qualified plug-in electric drive motor

Posted in: Energy Law, Transportation Law

7 hours ago Kepler’s third law is generalised after applying Newton’s Law of Gravity and laws of Motion. $$P^{2}=\frac{4\pi^{2}}{G(M1+M2)}(a^{3})$$ Where, M1 and M2 are the masses of the orbiting objects. Orbital Velocity Formula. Orbital velocity formula is used to calculate the orbital velocity of planet with mass M and radius R.

Posted in: Form Law

1 hours ago Charles Law Formula: V1/T1=V2/T2. This law was then used later on to determine the volume or temperature of a gas. still, What are the 3 gas laws? The gas laws consist of three primary laws:

Posted in: Form Law

3 hours ago In microeconomics, the law of demand is a fundamental principle which states that there is an inverse relationship between price and quantity demanded. In other words, "conditional on all else being equal, as the price of a good increases (↑), quantity demanded will decrease (↓); conversely, as the price of a good decreases (↓), quantity demanded will increase (↑)".

Posted in: Law Commons

8 hours ago The law of demand assumes that all determinants of demand, except price, remain unchanged. Demand can be visually represented by a demand curve within a graph called the demand schedule. Aside from price, factors that affect demand are consumer income, preferences, expectations, and prices of related commodities.

Posted in: Consumer Law

6 hours ago Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.

Posted in: Form Law, Sea Law

7 hours ago For any academic help you need, feel free to talk to our team for assistance and you will never regret your decision to work with us. We are reliable and established You can entrust all your academic work to course help online for original and high quality papers submitted on time.

Posted in: Trust Law

8 hours ago Ideal Gas Law Calculator . Ideal gas law calculator is an online tool for calculating gas pressure using the equation pv=nrt. This calculator can be used to calculate any of the values involved in the ideal gas law formula. What is an ideal gas? An ideal gas consists of perfectly elastic, unreactive point particles that move around randomly.

Posted in: Form Law

3 hours ago Boyle's law, also referred to as the Boyle–Mariotte law, or Mariotte's law (especially in France), is an experimental gas law that describes how the pressure of a gas tends to decrease as the volume of the container increases. A modern statement of Boyle's law is: The absolute pressure exerted by a given mass of an ideal gas is inversely proportional to the volume it occupies if the

Posted in: Law Commons

6 hours ago Antitrust Case Filings. Cases are listed alphabetically by the last name of individual defendants, by company name, or by the entity's first name. Amicus curiae briefs are listed by plaintiff's name. Numerical Listing - 123….

Posted in: Trust Law

1 hours ago Rate. Value, measure, or degree; a charge, payment, or price determined through the application of a mathematical formula or based upon a scale or standard. For example, an interest rate is determined by the ratio between the principal and interest. Rate is also used synonymously with tax. West's Encyclopedia of American Law, edition 2.

Posted in: Form Law

5 hours ago

Posted in: Law Commons

9 hours ago

Posted in: Law Commons

3 hours ago The Red Bull driver also saw his rival, seven-time world champion Lewis Hamilton, hit by another punishment and set to start from 10th on Sunday despite an impressive run from last to fifth. Ferrari's Carlos Sainz finished third, with Red Bull's Sergio Perez in fourth. McLaren's Lando Norris will inherit Hamilton's fifth position on the grid.

Posted in: Law Commons

Filter Type:

## New Popular Law

### What is the formula for charles'law and explanation?

Charles' Law Formula and Explanation. Charles' Law is a special case of the ideal gas law. It states that the volume of a fixed mass of a gas is directly proportional to the temperature. This law applies to ideal gases held at a constant pressure, where only the volume and temperature are allowed to change. Charles' Law is expressed as: V i /T i...

### How is charles'law related to the ideal gas law?

Charles' Law is a special case of the ideal gas law. It states that the volume of a fixed mass of a gas is directly proportional to the temperature. This law applies to ideal gases held at a constant pressure, where only the volume and temperature are allowed to change. Charles' Law is expressed as: V i/T i = V f/T f.

### Which is the best unit for solving Charles law?

It is to be noted here that the unit Kelvin is preferred for solving problems related to Charles’ Law, and not Celsius. Kelvin (T) is also known as the Absolute temperature scale. For converting a temperature to Kelvin scale, you add 273 to the temperature in the centigrade/Celsius scale.

### Are there any experiments to verify Charles's law?

There are a number of laboratory experiments to verify Charles's law. Some are modern while others are traditional. Irrespective of which method one uses the objective and result of an experiment remains the same. Charles's law relates volume to temperature at a constant pressure.


text:
• Subject:

...

• Topic:

...

The magnetic flux through a circuit of resistance R changes by an amount $\Delta \phi$ in time $\Delta t$, Then the total quantity of electric charge Q, which passing during this time through any point of the circuit is given by

(1) $Q=\frac{\Delta \varphi }{\Delta t}$

(2) $Q=\frac{\Delta \varphi }{\Delta t}×R$

(3) $Q=-\frac{\Delta \varphi }{\Delta t}+R$

(4) $Q=\frac{\Delta \varphi }{R}$


text:
# Wydawnictwa / Czasopisma IMPAN / Colloquium Mathematicum / Wszystkie zeszyty

## Transitivity of proximinality and norm attaining functionals

### Tom 104 / 2006

Colloquium Mathematicum 104 (2006), 1-19 MSC: 41A65, 41A50, 46B20. DOI: 10.4064/cm104-1-1

#### Streszczenie

We study the question of when the set of norm attaining functionals on a Banach space is a linear space. We show that this property is preserved by factor reflexive proximinal subspaces in $\widetilde {R(1)}$ spaces and generally by taking quotients by proximinal subspaces. We show, for ${\mathcal K}(\ell _2)$ and $c_0$-direct sums of families of reflexive spaces, the transitivity of proximinality for factor reflexive subspaces. We also investigate the linear structure of the set of norm attaining functionals on hyperplanes of $c_0$ and show that, for some particular hyperplanes of $c_0$, linearity and orthogonal linearity coincide for the set of norm attaining functionals.

#### Autorzy

Indian Institute of Science
Bangalore 560012, India
e-mail
• T. S. S. R. K. RaoStat-Math Unit
Indian Statistical Institute
R. V. College P.O.
Bangalore 560059, India
e-mail

## Przeszukaj wydawnictwa IMPAN

Zbyt krótkie zapytanie. Wpisz co najmniej 4 znaki.

Odśwież obrazek


text:
# Euler sequence

In mathematics, the Euler sequence is a particular exact sequence of sheaves on n-dimensional projective space over a ring. It shows that the sheaf of relative differentials is stably isomorphic to an (n + 1)-fold sum of the dual of the Serre twisting sheaf.

The Euler sequence generalizes to that of a projective bundle as well as a Grassmann bundle (see the latter article for this generalization.)

## Statement

For A a ring, there is an exact sequence of sheaves

${\displaystyle 0\to \Omega _{\mathbb {P} _{A}^{n}/A}^{1}\to {\mathcal {O}}_{\mathbb {P} _{A}^{n}}(-1)^{\oplus n+1}\to {\mathcal {O}}_{\mathbb {P} _{A}^{n}}\to 0.}$

It can be proved by defining a homomorphism ${\displaystyle S(-1)^{\oplus n+1}\to S,e_{i}\mapsto x_{i}}$ with ${\displaystyle S=A[x_{0},\ldots ,x_{n}]}$ and ${\displaystyle e_{i}=1}$ in degree 1, surjective in degrees ${\displaystyle \geq 1}$ and checking that locally on the n + 1 standard charts the kernel is isomorphic to the relative differential module.[1]

## Geometric interpretation

We assume that A is a field k.

The exact sequence above is equivalent to the sequence

${\displaystyle 0\to {\mathcal {O}}_{\mathbb {P} ^{n}}\to {\mathcal {O}}(1)^{\oplus (n+1)}\to {\mathcal {T}}_{\mathbb {P} ^{n}}\to 0}$,

where the last nonzero term is the tangent sheaf.

We consider V a n+1 dimensional vector space over k , and explain the exact sequence

${\displaystyle 0\to {\mathcal {O}}_{\mathbb {P} (V)}\to {\mathcal {O}}_{\mathbb {P} (V)}(1)\otimes V\to {\mathcal {T}}_{\mathbb {P} (V)}\to 0}$

This sequence is most easily understood by interpreting the central term as the sheaf of 1-homogeneous vector fields on the vector space V. There exists a remarkable section of this sheaf, the Euler vector field, tautologically defined by associating to a point of the vector space the identically associated tangent vector (ie. itself : it is the identity map seen as a vector field).

This vector field is radial in the sense that it vanishes uniformly on 0-homogeneous functions, that is, the functions that are invariant by homothetic rescaling, or "independent of the radial coordinate".

A function (defined on some open set) on ${\displaystyle \mathbb {P} (V)}$ gives rise by pull-back to a 0-homogeneous function on V (again partially defined). We obtain 1-homogeneous vector fields by multiplying the Euler vector field by such functions. This is the definition of the first map, and its injectivity is immediate.

The second map is related to the notion of derivation, equivalent to that of vector field. Recall that a vector field on an open set U of the projective space ${\displaystyle \mathbb {P} (V)}$ can be defined as a derivation of the functions defined on this open set. Pulled-back in V, this is equivalent to a derivation on the preimage of U that preserves 0-homogeneous functions. Any vector field on ${\displaystyle \mathbb {P} (V)}$ can be thus obtained, and the defect of injectivity of this mapping consists precisely of the radial vector fields.

We see therefore that the kernel of the second morphism identifies with the range of the first one.

## The canonical line bundle of projective spaces

By taking the highest exterior power, one sees that the canonical sheaf of a projective space is given by

${\displaystyle \omega _{\mathbb {P} _{A}^{n}/A}={\mathcal {O}}_{\mathbb {P} _{A}^{n}}(-(n+1))}$.

In particular, projective spaces are Fano varieties, because the canonical bundle is anti-ample and this line bundle has no non-zero global sections, so the geometric genus is 0.

## Notes

1. Theorem II.8.13 in Hartshorne 1977

## References

• Hartshorne, Robin (1977), Algebraic Geometry, Graduate Texts in Mathematics, 52, New York: Springer-Verlag, ISBN 978-0-387-90244-9, MR 0463157
• Rubei, Elena (2014), Algebraic Geometry, a concise dictionary, Berlin/Boston: Walter De Gruyter, ISBN 978-3-11-031622-3


text:
# How to Use Windows Azure Caching

This guide shows you how to get started using Windows Azure Caching. The samples are written in C# code and use the .NET API. The scenarios covered include configuring a cache cluster, configuring cache clients, adding and removing objects from the cache, storing ASP.NET session state in the cache, and enabling ASP.NET page output caching using the cache. For more information on using Windows Azure Caching, refer to the Next Steps section.

## What is Windows Azure Caching?What is Windows Azure Caching?

Windows Azure Caching provides a caching layer to your Windows Azure applications. Caching increases performance by temporarily storing information in-memory from other backend sources, and can reduce the costs associated with database transactions in the cloud. Windows Azure Caching includes the following features:

• Pre-built ASP.NET providers for session state and page output caching, enabling acceleration of web applications without having to modify application code.
• Caches any serializable managed object - for example: CLR objects, rows, XML, binary data.
• Consistent development model across both Windows Azure and Windows Server AppFabric.

Windows Azure Caching introduces a new way to perform caching by using a portion of the memory of the virtual machines that host the role instances in your Windows Azure cloud services (also known as hosted services). You have greater flexibility in terms of deployment options, the caches can be very large in size and have no cache specific quota restrictions.

Caching on role instances has the following advantages:

• Pay no premium for caching. You pay only for the compute resources that host the cache.
• Eliminates cache quotas and throttling.
• Offers greater control and isolation.
• Improved performance.
• Automatically sizes caches when roles are scaled in or out. Effectively scales the memory that is available for caching up or down when role instances are added or removed.
• Provides full-fidelity development time debugging.
• Supports the memcache protocol.

In addition, caching on role instances offers these configurable options:

• Configure a dedicated role for caching, or co-locate caching on existing roles.
• Make your cache available to multiple clients in the same cloud service deployment.
• Create multiple named caches with different properties.
• Optionally configure high availability on individual caches.
• Use expanded caching capabilities such as regions, tagging, and notifications.

This guide provides an overview of getting started with Windows Azure Caching. For more detailed information on these features that are beyond the scope of this getting started guide, see Overview of Windows Azure Caching.

## Getting Started with Windows Azure CachingGetting Started with Windows Azure Caching

Windows Azure Caching provides a way to enable caching using the memory that is on the virtual machines that host your role instances. The role instances that host your caches are known as a cache cluster. There are two deployment topologies for caching on role instances:

• Dedicated Role caching - The role instances are used exclusively for caching.
• Co-located Role caching - The cache shares the VM resources (bandwidth, CPU, and memory) with the application.

To use caching on role instances, you need to configure a cache cluster, and then configure the cache clients so they can access the cache cluster.

## Configure the cache clusterConfigure the cache cluster

To configure a Co-located Role cache cluster, select the role in which you wish to host the cache cluster. Right-click the role properties in Solution Explorer and choose Properties.

Switch to the Caching tab, check the Enable Caching checkbox, and specify the desired caching options. When caching is enabled in a Worker Role or ASP.NET Web Role, the default configuration is Co-located Role caching with 30% of the memory of the role instances allocated for caching. A default cache is automatically configured, and additional named caches can be created if desired, and these caches will share the allocated memory.

To configure a Dedicated Role cache cluster, add a Cache Worker Role to your project.

When a Cache Worker Role is added to a project, the default configuration is Dedicated Role caching.

Once caching is enabled, the cache cluster storage account can be configured. Windows Azure Caching requires a Windows Azure storage account. This storage account is used to hold configuration data about the cache cluster that is accessed from all virtual machines that make up the cache cluster. This storage account is specified on the Caching tab of the cache cluster role property page, just above the Named Cache Settings.

If this storage account is not configured the roles will fail to start.

The size of the cache is determined by a combination of the VM size of the role, the instance count of the role, and whether the cache cluster is configured as a dedicated role or co-located role cache cluster.

This section provides a simplified overview on configuring the cache size. For more information on cache size and other capacity planning considerations, see Windows Azure Caching Capacity Planning Considerations.

To configure the virtual machine size and the number of role instances, right-click the role properties in Solution Explorer and choose Properties.

Switch to the Configuration tab. The default Instance count is 1, and the default VM size is Small.

The total memory for the VM sizes is as follows:

• Small: 1.75 GB
• Medium: 3.5 GB
• Large: 7 GB
• ExtraLarge: 14 GB

These memory sizes represent the total amount of memory available to the VM which is shared across the OS, cache process, cache data, and application. For more information on configuring Virtual Machine Sizes, see How to Configure Virtual Machine Sizes. Note that cache is unsupported on ExtraSmall VM sizes.

When Co-located Role caching is specified, the cache size is determined by taking the specified percentage of the virtual machine memory. When Dedicated Role caching is specified, all of the available memory of the virtual machine is used for caching. If two role instances are configured, the combined memory of the virtual machines is used. This forms a cache cluster where the available caching memory is distributed across multiple role instances but presented to the clients of the cache as a single resource. Configuring additional role instances increases the cache size in the same manner. To determine the settings needed to provision a cache of the desired size, you can use the Capacity Planning Spreadsheet which is covered in Windows Azure Caching Capacity Planning Considerations.

Once the cache cluster is configured, you can configure the cache clients to allow access to the cache.

## Configure the cache clientsConfigure the cache clients

To access a Windows Azure Caching cache, the clients must be within the same deployment. If the cache cluster is a dedicated role cache cluster, then the clients are other roles in the deployment. If the cache cluster is a co-located role cache cluster, then the clients could be either the other roles in the deployment, or the roles themselves that host the cache cluster. A NuGet package is provided that can be used to configure each client role that accesses the cache. To configure a role to access a cache cluster using the Caching NuGet package, right-click the role project in Solution Explorer and choose Manage NuGet Packages.

Select Windows Azure Caching, click Install, and then click I Accept.

If Windows Azure Caching does not appear in the list type WindowsAzure.Caching into the Search Online text box and select it from the results.

The NuGet package does several things: it adds the required configuration to the config file of the role, it adds a cache client diagnostic level setting to the ServiceConfiguration.cscfg file of the Windows Azure application, and it adds the required assembly references.

For ASP.NET web roles, the Caching NuGet package also adds two commented out sections to web.config. The first section enables session state to be stored in the cache, and the second section enables ASP.NET page output caching. For more information, see How To: Store ASP.NET Session State in the Cache and How To: Store ASP.NET Page Output Caching in the Cache.

The NuGet package adds the following configuration elements into your role's web.config or app.config. A dataCacheClients section and a cacheDiagnostics section are added under the configSections element. If there is no configSections element present, one is created as a child of the configuration element.

<configSections>

</configSections>

These new sections include references to a dataCacheClients element and a cacheDiagnostics element. These elements are also added to the configuration element.

<dataCacheClients>
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="[cache cluster role name]" />

</dataCacheClient>
</dataCacheClients>
<cacheDiagnostics>
<crashDump dumpLevel="Off" dumpStorageQuotaInMB="100" />
</cacheDiagnostics>

After the configuration is added, replace [cache cluster role name] with the name of the role that hosts the cache cluster.

If [cache cluster role name] is not replaced with the name of the role that hosts the cache cluster, then a TargetInvocationException will be thrown when the cache is accessed with an inner DatacacheException with the message "No such role exists".

The NuGet package also adds a ClientDiagnosticLevel setting to the ConfigurationSettings of the cache client role in ServiceConfiguration.cscfg. The following example is the WebRole1 section from a ServiceConfiguration.cscfg file with a ClientDiagnosticLevel of 1, which is the default ClientDiagnosticLevel.

<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>

<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel"
value="1" />
</ConfigurationSettings>
</Role>

Windows Azure Caching provides both a cache server and a cache client diagnostic level. The diagnostic level is a single setting that configures the level of diagnostic information collected for caching. For more information, see Troubleshooting and Diagnostics for Windows Azure Caching

The NuGet package also adds references to the following assemblies:

• Microsoft.ApplicationServer.Caching.Client.dll
• Microsoft.ApplicationServer.Caching.Core.dll
• Microsoft.WindowsFabric.Common.dll
• Microsoft.WindowsFabric.Data.Common.dll
• Microsoft.ApplicationServer.Caching.AzureCommon.dll
• Microsoft.ApplicationServer.Caching.AzureClientHelper.dll

If your role is an ASP.NET Web Role, the following assembly reference is also added:

• Microsoft.Web.DistributedCache.dll.

These assemblies are located in the C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\ref\Caching\ folder.

Once your client project is configured for caching, you can use the techniques described in the following sections for working with your cache.

## Working with CachesWorking with Caches

The steps in this section describe how to perform common tasks with caching.

## Create a DataCache ObjectHow To: Create a DataCache Object

In order to programatically work with a cache, you need a reference to the cache. Add the following to the top of any file from which you want to use Windows Azure Caching:

using Microsoft.ApplicationServer.Caching;

If Visual Studio doesn't recognize the types in the using statement even after installing the Caching NuGet package, which adds the necessary references, ensure that the target profile for the project is .NET Framework 2.0 or higher, and be sure to select one of the profiles that does not specify Client Profile. For instructions on configuring cache clients, see Configure the cache clients.

There are two ways to create a DataCache object. The first way is to simply create a DataCache, passing in the name of the desired cache.

DataCache cache = new DataCache("default");

Once the DataCache is instantiated, you can use it to interact with the cache, as described in the following sections.

To use the second way, create a new DataCacheFactory object in your application using the default constructor. This causes the cache client to use the settings in the configuration file. Call either the GetDefaultCache method of the new DataCacheFactory instance which returns a DataCache object, or the GetCache method and pass in the name of your cache. These methods return a DataCache object that can then be used to programmatically access the cache.

// Cache client configured by settings in application configuration file.
DataCacheFactory cacheFactory = new DataCacheFactory();
DataCache cache = cacheFactory.GetDefaultCache();
// Or DataCache cache = cacheFactory.GetCache("MyCache");
// cache can now be used to add and retrieve items.

## Add and Retrieve an Object from the CacheHow To: Add and Retrieve an Object from the Cache

To add an item to the cache, the Add method or the Put method can be used. The Add method adds the specified object to the cache, keyed by the value of the key parameter.

// Add the string "value" to the cache, keyed by "item"
cache.Add("item", "value");

If an object with the same key is already in the cache, a DataCacheException will be thrown with the following message:

ErrorCode:SubStatus: An attempt is being made to create an object with a Key that already exists in the cache. Caching will only accept unique Key values for objects.

To retrieve an object with a specific key, the Get method can be used. If the object exists, it is returned, and if it does not, null is returned.

// Add the string "value" to the cache, keyed by "key"
object result = cache.Get("Item");
if (result == null)
{
// "Item" not in cache. Obtain it from specified data source
string value = GetItemValue(...);
}
else
{
// "Item" is in cache, cast result to correct type.
}

The Put method adds the object with the specified key to the cache if it does not exist, or replaces the object if it does exist.

// Add the string "value" to the cache, keyed by "item". If it exists,
// replace it.
cache.Put("item", "value");

## Specify the Expiration of an Object in the CacheHow To: Specify the Expiration of an Object in the Cache

By default items in the cache expire 10 minutes after they are placed in the cache. This can be configured in the Time to Live (min) setting in the role properties of the role that hosts the cache cluster.

There are three types of Expiration Type: None, Absolute, and Sliding Window. These configure how Time to Live (min) is used to determine expiration. The default Expiration Type is Absolute, which means that the countdown timer for an item's expiration begins when the item is placed into the cache. Once the specified amount of time has elapsed for an item, the item expires. If Sliding Window is specified, then the expiration countdown for an item is reset each time the item is accessed in the cache, and the item will not expire until the specified amount of time has elapsed since its last access. If None is specified, then Time to Live (min) must be set to 0, and items will not expire, and will remain valid as long as they are in the cache.

If a longer or shorter timeout interval than what is configured in the role properties is desired, a specific duration can be specified when an item is added or updated in the cache by using the overload of Add and Put that take a TimeSpan parameter. In the following example, the string value is added to cache, keyed by item, with a timeout of 30 minutes.

// Add the string "value" to the cache, keyed by "item"
cache.Add("item", "value", TimeSpan.FromMinutes(30));

To view the remaining timeout interval of an item in the cache, the GetCacheItem method can be used to retrieve a DataCacheItem object that contains information about the item in the cache, including the remaining timeout interval.

// Get a DataCacheItem object that contains information about
// "item" in the cache. If there is no object keyed by "item" null
// is returned.
DataCacheItem item = cache.GetCacheItem("item");
TimeSpan timeRemaining = item.Timeout;

## Store ASP.NET Session State in the CacheHow To: Store ASP.NET Session State in the Cache

The Session State Provider for Windows Azure Caching is an out-of-process storage mechanism for ASP.NET applications. This provider enables you to store your session state in a Windows Azure cache rather than in-memory or in a SQL Server database. To use the caching session state provider, first configure your cache cluster, and then configure your ASP.NET application for caching using the Caching NuGet package as described in Getting Started with Windows Azure Caching. When the Caching NuGet package is installed, it adds a commented out section in web.config that contains the required configuration for your ASP.NET application to use the Session State Provider for Windows Azure Caching.

If your web.config does not contain this commented out section after installing the Caching NuGet package, ensure that the latest NuGet Package Manager is installed from NuGet Package Manager Installation, and then uninstall and reinstall the package.

To enable the Session State Provider for Windows Azure Caching, uncomment the specified section. The default cache is specified in the provided snippet. To use a different cache, specify the desired cache in the cacheName attribute.

For more information about using the Caching service session state provider, see Session State Provider for Windows Azure Caching.

## Store ASP.NET Page Output Caching in the CacheHow To: Store ASP.NET Page Output Caching in the Cache

The Output Cache Provider for Windows Azure Caching is an out-of-process storage mechanism for output cache data. This data is specifically for full HTTP responses (page output caching). The provider plugs into the new output cache provider extensibility point that was introduced in ASP.NET 4. To use the output cache provider, first configure your cache cluster, and then configure your ASP.NET application for caching using the Caching NuGet package, as described in Getting Started with Windows Azure Caching. When the Caching NuGet package is installed, it adds the following commented out section in web.config that contains the required configuration for your ASP.NET application to use the Output Cache Provider for Windows Azure Caching.

If your web.config does not contain this commented out section after installing the Caching NuGet package, ensure that the latest NuGet Package Manager is installed from NuGet Package Manager Installation, and then uninstall and reinstall the package.

To enable the Output Cache Provider for Windows Azure Caching, uncomment the specified section. The default cache is specified in the provided snippet. To use a different cache, specify the desired cache in the cacheName attribute.

Add an OutputCache directive to each page for which you wish to cache the output.

<%@ OutputCache Duration="60" VaryByParam="*" %>

In this example the cached page data will remain in the cache for 60 seconds, and a different version of the page will be cached for each parameter combination. For more information on the available options, see OutputCache Directive.

For more information about using the Output Cache Provider for Windows Azure Caching, see Output Cache Provider for Windows Azure Caching.

## Next StepsNext Steps

Now that you've learned the basics of Windows Azure Caching, follow these links to learn how to do more complex caching tasks.